]> granicus.if.org Git - clang/commitdiff
remove TranslationUnit from ParseAST.
authorChris Lattner <sabre@nondot.org>
Sat, 28 Mar 2009 04:13:34 +0000 (04:13 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 28 Mar 2009 04:13:34 +0000 (04:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67911 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/ParseAST.h
lib/Sema/ParseAST.cpp
tools/clang-cc/clang.cpp

index b41c2da1d41d85c96e69e0ccb816ec71b05ed87a..882460029d9f2831f35bd29d8431903168e6bd3c 100644 (file)
 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
 
index 756a398b4c14afa7734dbe98eb9b0457c4559ef3..bcff1c8cfbc75376f893df72a77f515717038464 100644 (file)
@@ -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();
index 9bd6dfb805f1f41724b81bc1a2153ab4c7af4ea0..9ab1dd39a467817ea393bb5aa50231b7063d615b 100644 (file)
@@ -1476,7 +1476,6 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
 
   if (Consumer) {
     llvm::OwningPtr<ASTContext> ContextOwner;
-    llvm::OwningPtr<TranslationUnit> 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)