From: Chris Lattner Date: Sat, 28 Mar 2009 04:13:34 +0000 (+0000) Subject: remove TranslationUnit from ParseAST. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3599dbe94ed8229b4a0eca0b066129e381ccb277;p=clang remove TranslationUnit from ParseAST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67911 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/ParseAST.h b/include/clang/Sema/ParseAST.h index b41c2da1d4..882460029d 100644 --- a/include/clang/Sema/ParseAST.h +++ b/include/clang/Sema/ParseAST.h @@ -17,13 +17,14 @@ namespace clang { class Preprocessor; class ASTConsumer; - class TranslationUnit; + class ASTContext; /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as - /// the file is parsed. This inserts the parsed decls into TU. + /// the file is parsed. This inserts the parsed decls into the translation unit + /// held by Ctx. /// void ParseAST(Preprocessor &pp, ASTConsumer *C, - TranslationUnit &TU, bool PrintStats = false); + ASTContext &Ctx, bool PrintStats = false); } // end namespace clang diff --git a/lib/Sema/ParseAST.cpp b/lib/Sema/ParseAST.cpp index 756a398b4c..bcff1c8cfb 100644 --- a/lib/Sema/ParseAST.cpp +++ b/lib/Sema/ParseAST.cpp @@ -25,24 +25,25 @@ using namespace clang; //===----------------------------------------------------------------------===// /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as -/// the file is parsed. This inserts the parsed decls into TU. +/// the file is parsed. This inserts the parsed decls into the translation unit +/// held by Ctx. /// void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, - TranslationUnit &TU, bool PrintStats) { + ASTContext &Ctx, bool PrintStats) { // Collect global stats on Decls/Stmts (until we have a module streamer). if (PrintStats) { Decl::CollectingStats(true); Stmt::CollectingStats(true); } - Sema S(PP, TU.getContext(), *Consumer); + Sema S(PP, Ctx, *Consumer); Parser P(PP, S); PP.EnterMainSourceFile(); // Initialize the parser. P.Initialize(); - Consumer->Initialize(TU.getContext()); + Consumer->Initialize(Ctx); Parser::DeclTy *ADecl; @@ -56,12 +57,12 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, } }; - Consumer->HandleTranslationUnit(TU.getContext()); + Consumer->HandleTranslationUnit(Ctx); if (PrintStats) { fprintf(stderr, "\nSTATISTICS:\n"); P.getActions().PrintStats(); - TU.getContext().PrintStats(); + Ctx.PrintStats(); Decl::PrintStats(); Stmt::PrintStats(); Consumer->PrintStats(); diff --git a/tools/clang-cc/clang.cpp b/tools/clang-cc/clang.cpp index 9bd6dfb805..9ab1dd39a4 100644 --- a/tools/clang-cc/clang.cpp +++ b/tools/clang-cc/clang.cpp @@ -1476,7 +1476,6 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, if (Consumer) { llvm::OwningPtr ContextOwner; - llvm::OwningPtr TranslationUnitOwner; ContextOwner.reset(new ASTContext(PP.getLangOptions(), PP.getSourceManager(), @@ -1484,17 +1483,14 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, PP.getIdentifierTable(), PP.getSelectorTable(), /* FreeMemory = */ !DisableFree)); - TranslationUnitOwner.reset(new TranslationUnit(*ContextOwner.get())); - ParseAST(PP, Consumer.get(), *TranslationUnitOwner.get(), Stats); + ParseAST(PP, Consumer.get(), *ContextOwner.get(), Stats); // If in -disable-free mode, don't deallocate these when they go out of // scope. - if (DisableFree) { + if (DisableFree) ContextOwner.take(); - TranslationUnitOwner.take(); - } } if (VerifyDiagnostics)