How to register a clang preprocessor plugin? -


i trying write clang plugin preprocessor using c++ interface , appreciate help. i've read clang plugin tutorials using astfrontendactions, , tried searching preprocessor plugins online, i'm little further was. keep finding references same tutorial on , over, or guidance using c interface.

after digging through header files 3 days, think i've narrowed plugin's parent class clang::preprocessorfrontendaction, can't sure. build errors when try register plugin because wants ast related. (i think because function tutorial tells me use goes this header definition, uses clang::pluginastaction.)

the function tutorial tells me register is:

static frontendpluginregistry::add<myplugin> x("my-plugin-name", "my plugin description");

i've never worked clang before, i'm diving in head first. after week, feel i'm drowning in header files. assistance appreciated not creative enough apply ast tutorial preprocessor problem.

edit: so, i've gotten past build errors , builds fine now. unfortunately have no idea whether i've actually registered plugin. in every function try print screen see nothing come out when run it.

here have far.

//plugintest.h template class llvm::registry<clang::preprocessorfrontendaction>;  namespace clang {     typedef llvm::registry<preprocessorfrontendaction> preprocessorfrontendpluginregistry; } // namespace clang   //plugintest.cpp  namespace {  class testpreprocessorfrontendaction : public preprocessorfrontendaction{     public:         testpreprocessorfrontendaction(){             cerr << "we have constructor.\n";         }      protected:         virtual void executeaction() {}          bool beginsourcefileaction(compilerinstance &ci, stringref filename){             setcompilerinstance(&ci);             cerr << "inside beginsourcefileaction. \n";             return true;         }          //this function should not called preprocessorfrontendaction         //and should overloaded return abort. or headers.         virtual std::unique_ptr<astconsumer> createastconsumer(compilerinstance &ci, stringref infile) {              cerr << "inside badness.\n";              return null ptr;          }           void endsourcefileaction() {              cerr << "we have ignition?\n";          } };  }   static preprocessorfrontendpluginregistry::add<testpreprocessorfrontendaction> x(     "test-plugin",     "test preprocessor plugin"); 


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -