示例#1
0
	bool parseAST(const char* szSourceCodeFilePath, clang::ast_matchers::MatchFinder finder)
	{
		// create the compiler instance setup for this file as main file
		prepareCompilerforFile(szSourceCodeFilePath);

		std::unique_ptr<clang::ASTConsumer> pAstConsumer (finder.newASTConsumer());
		
		clang::DiagnosticConsumer& diagConsumer = m_CompilerInstance.getDiagnosticClient();
		diagConsumer.BeginSourceFile(m_CompilerInstance.getLangOpts(), &m_CompilerInstance.getPreprocessor());
		clang::ParseAST(m_CompilerInstance.getPreprocessor(), pAstConsumer.get(), m_CompilerInstance.getASTContext());
		diagConsumer.EndSourceFile();

		return diagConsumer.getNumErrors() != 0;
	}