Frontend: Allow passing -cc1 level arguments to plugins. Patch by Troy Straszheim!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106113 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/examples/PrintFunctionNames/PrintFunctionNames.cpp b/examples/PrintFunctionNames/PrintFunctionNames.cpp
index 5b7b66a..397cf84 100644
--- a/examples/PrintFunctionNames/PrintFunctionNames.cpp
+++ b/examples/PrintFunctionNames/PrintFunctionNames.cpp
@@ -31,11 +31,24 @@
}
};
-class PrintFunctionNamesAction : public ASTFrontendAction {
+class PrintFunctionNamesAction : public PluginASTAction {
protected:
ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef) {
return new PrintFunctionsConsumer();
}
+
+ bool ParseArgs(const std::vector<std::string>& args) {
+ for (unsigned i=0; i<args.size(); ++i)
+ llvm::errs() << "PrintFunctionNames arg = " << args[i] << "\n";
+ if (args.size() && args[0] == "help")
+ PrintHelp(llvm::errs());
+
+ return true;
+ }
+ void PrintHelp(llvm::raw_ostream& ros) {
+ ros << "Help for PrintFunctionNames plugin goes here\n";
+ }
+
};
}