[cfe-dev] Parsing C++ Header File

Raghavendra Keshav ragavendrakk at gmail.com
Wed May 29 03:17:51 PDT 2013


Hi,

Problem: Want to parse C++ classes in a header file and generate
              serialize and deserialize methods for this class.
              example:
              sample.h
               #include ....
                class Test
                {
                    std::map<int,string> myMap;
                    int i;
                    string s;
                    A obj;
                };

==>Transform it as below
                class Test
                {
                    std::map<int,string> myMap;
                    int i;
                    string s;
                    A obj;
                   public:
                    void* encode();
                };

            void*     Test::encode()
            {
                for( i- 0; i<myMap.size(); i++)
                encodeString();

                 encodeInt();

                 encodeString();
                 obj.encode();

               return buf;
            }

With the tutotials around i could setup the compiler instance
and ASTConsumer and ASTVisitor/
In the ASTRecursive visitor... i could overload visitRecordDecl(...);
On getting a CXXRecordDecl...i have iterated through FieldDecl
Now From FieldDecl...i want to extract information like
it is map made from int and string...
Am not able get the relationship of FieldDecl to CTemplateDecl...
and from CTemplateDecl how to extract the params?

Pls provide direction how to proceed further...

regards
ragha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130529/f08cea0e/attachment.html>


More information about the cfe-dev mailing list