<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi,<br>
<br>
with clang 3.5, when I wanted to parse a source file, I created a
compiler instance and a new class that inherit from the class
ASTConsumer like this :<br>
<br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
ci = new clang::CompilerInstance()<br>
ci.createDiagnostics();<br>
ci.createFileManager();<br>
ci.createSourceManager(ci.getFileManager());<br>
std::shared_ptr<clang::TargetOptions> pto =
std::make_shared<clang::TargetOptions>();<br>
pto->Triple = llvm::sys::getDefaultTargetTriple();<br>
clang::TargetInfo *pti =
clang::TargetInfo::CreateTargetInfo(m_ci.getDiagnostics(), pto);<br>
ci.setTarget(pti);<br>
ci.createPreprocessor(clang::TU_Complete);<br>
... <br>
//add source file and the headers paths<br>
...<br>
MyASTConsumer * myASTConsumerClassInstance = new MyASTConsumer;<br>
ci.setASTConsumer(myASTConsumerClassInstance);<br>
...<br>
//parse the header file<br>
<br>
with the ASTConsumer :<br>
<br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
class MyASTConsumer : public clang::ASTConsumer<br>
{<br>
MyASTConsumer()<br>
~MyASTConsumer() {};<br>
virtual bool HandleTopLevelDecl( clang::DeclGroupRef d);<br>
virtual void HandleTagDeclDefinition( clang::TagDecl * d);<br>
private:<br>
std::vector<clang::TagDecl *> m_my_tags;<br>
}<br>
<br>
Now with clang 3.6, the CompilerInstance::setASTConsumer methods
asks for a std::unique_ptr<ASTConsumer> as argument. How to
adapt my previous code with the new api.<br>
<br>
Thanks<br>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</body>
</html>