commit 766b5ef80dc35980413b601117608c05c1352c73
parent b402e6e6e2f6ce904527e4d7b9a1195475a4bbb9
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Tue, 29 Mar 2016 22:08:01 -0600
instrument: portability goo
Diffstat:
3 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/instrument/instrument_action.cc b/instrument/instrument_action.cc
@@ -15,7 +15,11 @@
#include "runtime_h.h"
+#ifdef __APPLE__
+std::unique_ptr<clang::ASTConsumer>
+#else
clang::ASTConsumer *
+#endif
InstrumentAction::CreateASTConsumer(clang::CompilerInstance &CI, clang::StringRef file)
{
// llvm::errs() << "** Creating AST consumer for: " << file << "\n";
@@ -24,7 +28,11 @@ InstrumentAction::CreateASTConsumer(clang::CompilerInstance &CI, clang::StringRe
// Hang onto a reference to this so we can read from it later
InstrumentASTConsumer = new RewriteASTConsumer(TheRewriter);
+#ifdef __APPLE__
+ return std::unique_ptr<clang::ASTConsumer>(InstrumentASTConsumer);
+#else
return InstrumentASTConsumer;
+#endif
}
unsigned int
diff --git a/instrument/instrument_action.h b/instrument/instrument_action.h
@@ -30,7 +30,11 @@ public:
InstrumentAction() {};
void EndSourceFileAction() override;
+#ifdef __APPLE__
+ std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(clang::CompilerInstance &, clang::StringRef) override;
+#else
clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance &, clang::StringRef) override;
+#endif
private:
clang::Rewriter TheRewriter;
diff --git a/instrument/main.cc b/instrument/main.cc
@@ -81,7 +81,11 @@ instrument(int argc, char *argv[], std::vector<std::string> const &source_files)
// that will return a new MyFrontendAction object every time. To
// further customize this, we could create our own factory class.
// int ret = Tool.run(new MFAF(inst_files));
+#ifdef __APPLE__
+ int ret = Tool.run(&(*clang::tooling::newFrontendActionFactory<InstrumentAction>()));
+#else
int ret = Tool.run(clang::tooling::newFrontendActionFactory<InstrumentAction>());
+#endif
if (ret)
warnx("Instrumentation failed");
return ret;