[cfe-dev] add method to a existing class and save to source file

罗 金才 via cfe-dev cfe-dev at lists.llvm.org
Wed May 2 18:31:32 PDT 2018


Dear Clang Developers:
      I have a class named  classA  in a.h and a.cpp file. it have some methods, I want to add a new method definition to a.h and add new method body after last method use clang . How to do it ?
      I know the  RecursiveASTVisitor::VisitCXXRecordDecl(...) can visit CXXRecordDecl and CXXMethodDecl , Rewriter  be used to write code . but how to create new method definition and body to a.h and a.cpp?

//a.h file
classA {
protected:
     int filed;
 public:
     void method1();
     void method2();
                                    //insert a new method
}

//a.cpp file

void classA::method1()
{
        ..........
}

void classA::method2()
{
       ...........
}

                               // inset new method body


Yours truly

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180503/52acc611/attachment.html>


More information about the cfe-dev mailing list