[cfe-dev] How to use PragmaHandler in an ASTFrontEndAction?

Marcel Schaible via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 27 08:03:38 PDT 2017


Hi,

how can I instantiate a PragmaHandler for a user defined pragma in an 
ASTFrontEndAction?

Thanks

Marcel

<-- snippet-->

class MyPragmaHandler : public PragmaHandler { ...  }

class MyFrontendAction : public ASTFrontendAction {
public:
...

   std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
                                                  StringRef file) override {
     return llvm::make_unique<MyASTConsumer>(TheRewriter);
   }
};

int main(int argc, const char **argv) {
   CommonOptionsParser op(argc, argv, ToolingSampleCategory);
   ClangTool Tool(op.getCompilations(), op.getSourcePathList());
   return Tool.run(newFrontendActionFactory<MyFrontendAction>().get());
}




More information about the cfe-dev mailing list