[cfe-dev] Clang::preprocessor handle include directives
Anna Lu
annaruben85 at gmail.com
Fri Apr 29 00:18:19 PDT 2011
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110429/bd435c76/attachment.html>
More information about the cfe-dev
mailing list