It seems:<br> clang::ParseAST(m_preprocessor, m_ast_handler, a); // a is clang::ASTContext.<br>I add the main source file to m_preprocessor and it works.<br><br>Regards,<br>Anna.<br><br><br><br><div class="gmail_quote">On Fri, Apr 29, 2011 at 1:42 PM, Hendrik vP <span dir="ltr"><<a href="mailto:variadic.template@googlemail.com">variadic.template@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>Seems right to me. Are you sure that m_preprocessor is the preprocessor</div><div>used by clang?</div>
<br><div class="gmail_quote"><div><div></div><div class="h5">2011/4/29 Anna Lu <span dir="ltr"><<a href="mailto:annaruben85@gmail.com" target="_blank">annaruben85@gmail.com</a>></span><br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">Hi,<br> <br>would anybody help me to handle directives file parsing AST.<br>
<br>I have tried the following, but it does not help:<br>
<br>llvm_include_handler* h = new llvm_include_handler;<br>m_preprocessor->addPPCallbacks(h); // m_preprocessor is type of clang::Preprocessor*<br>
<br>where llvm_include_handler is defined as:<br><br>class llvm_include_handler :<br>        public clang::PPCallbacks<br>{<br>public:<br>         virtual void InclusionDirective(clang::SourceLocation,<br>         const clang::Token& ,<br>


         llvm::StringRef FileName,<br>         bool IsAngled,<br>         const clang::FileEntry*,<br>         clang::SourceLocation,<br>         llvm::StringRef SearchPath,<br>         llvm::StringRef RelativePath)<br>         {<br>


                 std::cout << "include "<< std::endl;<br>                 std::cout << FileName.str() << std::endl;<br>                 std::cout << "IsAngled " << IsAngled << std::endl;<br>


                 std::cout << SearchPath.str() << std::endl;<br>                 std::cout << RelativePath.str() << std::endl;<br>         }<br><br>        virtual ~llvm_include_handler() throw()<br>


        {}<br>};<br><br>than I call clang::ParseAST() to parse the AST nodes with my ASTConsumer. The InclusionDirective is not called.<br>What have I missed.<br><br>Thanks,<br><font color="#888888">Anna.<br>
</font><br></div></div>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>