[cfe-dev] Clang::preprocessor handle include directives

Hendrik vP variadic.template at googlemail.com
Fri Apr 29 01:42:30 PDT 2011


Seems right to me. Are you sure that m_preprocessor is the preprocessor
used by clang?

2011/4/29 Anna Lu <annaruben85 at gmail.com>

> Hi,
>
> would anybody help me to handle directives file parsing AST.
>
> I have tried the following, but it does not help:
>
> llvm_include_handler* h = new llvm_include_handler;
> m_preprocessor->addPPCallbacks(h); // m_preprocessor is type of
> clang::Preprocessor*
>
> where llvm_include_handler is defined as:
>
> class llvm_include_handler :
>         public clang::PPCallbacks
> {
> public:
>          virtual void InclusionDirective(clang::SourceLocation,
>          const clang::Token& ,
>          llvm::StringRef FileName,
>          bool IsAngled,
>          const clang::FileEntry*,
>          clang::SourceLocation,
>          llvm::StringRef SearchPath,
>          llvm::StringRef RelativePath)
>          {
>                  std::cout << "include "<< std::endl;
>                  std::cout << FileName.str() << std::endl;
>                  std::cout << "IsAngled " << IsAngled << std::endl;
>                  std::cout << SearchPath.str() << std::endl;
>                  std::cout << RelativePath.str() << std::endl;
>          }
>
>         virtual ~llvm_include_handler() throw()
>         {}
> };
>
> than I call clang::ParseAST() to parse the AST nodes with my ASTConsumer.
> The InclusionDirective is not called.
> What have I missed.
>
> Thanks,
> Anna.
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110429/cae88f57/attachment.html>


More information about the cfe-dev mailing list