[cfe-dev] Clang::preprocessor handle include directives
Anna Lu
annaruben85 at gmail.com
Fri Apr 29 02:51:47 PDT 2011
It seems:
clang::ParseAST(m_preprocessor, m_ast_handler, a); // a is
clang::ASTContext.
I add the main source file to m_preprocessor and it works.
Regards,
Anna.
On Fri, Apr 29, 2011 at 1:42 PM, Hendrik vP <
variadic.template at googlemail.com> wrote:
> 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
>>
>>
>
> _______________________________________________
> 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/29283e09/attachment.html>
More information about the cfe-dev
mailing list