From c90eaf923407611b711e7962b70fe84a6d41ecd9 Mon Sep 17 00:00:00 2001 From: triton Date: Thu, 4 Apr 2013 15:32:38 +0100 Subject: [PATCH] Initialize the semantic analysis consumer. --- src/Parser/Parser.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Parser/Parser.cpp b/src/Parser/Parser.cpp index c4ecd312..6c1f8173 100644 --- a/src/Parser/Parser.cpp +++ b/src/Parser/Parser.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include @@ -1600,12 +1602,6 @@ Cxxi::Declaration^ Parser::WalkDeclaration(clang::Decl* D, clang::TypeLoc* TL, //-----------------------------------// -struct ParseConsumer : public clang::ASTConsumer -{ - virtual ~ParseConsumer() { } - virtual bool HandleTopLevelDecl(clang::DeclGroupRef) { return true; } -}; - struct Diagnostic { clang::SourceLocation Location; @@ -1645,7 +1641,11 @@ ParserResult^ Parser::Parse(const std::string& File) return res; } - C->setASTConsumer(new ParseConsumer()); + auto SC = new clang::SemaConsumer(); + C->setASTConsumer(SC); + + C->createSema(clang::TU_Complete, 0); + SC->InitializeSema(C->getSema()); auto DiagClient = new DiagnosticConsumer(); C->getDiagnostics().setClient(DiagClient); @@ -1671,9 +1671,9 @@ ParserResult^ Parser::Parse(const std::string& File) clang::DiagnosticConsumer* client = C->getDiagnostics().getClient(); client->BeginSourceFile(C->getLangOpts(), &C->getPreprocessor()); - ParseAST(C->getPreprocessor(), &C->getASTConsumer(), C->getASTContext(), - /*PrintStats=*/false, clang::TU_Complete, 0, - /*SkipFunctionBodies=*/true); + + ParseAST(C->getSema(), /*PrintStats=*/false, /*SkipFunctionBodies=*/true); + client->EndSourceFile(); // Convert the diagnostics to the managed types