]> granicus.if.org Git - clang/commitdiff
Added "InitializeTU" to ASTConsumer. This is used by Sema::ParseAST to pass a
authorTed Kremenek <kremenek@apple.com>
Sat, 31 May 2008 20:11:04 +0000 (20:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Sat, 31 May 2008 20:11:04 +0000 (20:11 +0000)
TranslationUnit object instead of an ASTContext. By default it calls
Initialize(ASTConstext& Context) (to match with the current interface used by
most ASTConsumers).

Modified the ObjC-Rewriter to use InitializeTU, and to tell the TranslationUnit
to not free its Decls.  This is a workaround for: <rdar://problem/5966749>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51825 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/ASTConsumers.cpp
Driver/RewriteObjC.cpp
include/clang/AST/ASTConsumer.h
lib/AST/ASTConsumer.cpp
lib/Sema/ParseAST.cpp

index ba9fc90f034864a9e6a8866b648232b024ea5934..9ab6157cfaa3d7e88c241a998eef664f37d6f041 100644 (file)
@@ -877,9 +877,8 @@ public:
     
   virtual ~ASTSerializer() { delete TU; }
   
-  virtual void Initialize(ASTContext &Context) {
-    if (!TU) TU = new TranslationUnit(Context, lang);
-    TU->SetOwnsDecls(false);
+  virtual void InitializeTU(TranslationUnit &TU) {
+    TU.SetOwnsDecls(false);
   }
   
   virtual void HandleTopLevelDecl(Decl *D) {
index c523b03d5682305d9045fbc72d5fccca1cc730a1..f679e554d092d4a962c12e693e05a46f8ef84be9 100644 (file)
@@ -15,6 +15,7 @@
 #include "clang/Rewrite/Rewriter.h"
 #include "clang/AST/AST.h"
 #include "clang/AST/ASTConsumer.h"
+#include "clang/AST/TranslationUnit.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/Diagnostic.h"
@@ -94,7 +95,12 @@ namespace {
     
     static const int OBJC_ABI_VERSION =7 ;
   public:
-    void Initialize(ASTContext &context);
+    virtual void Initialize(ASTContext &context);
+
+    virtual void InitializeTU(TranslationUnit &TU) {
+      TU.SetOwnsDecls(false);
+      Initialize(TU.getContext());
+    }
     
 
     // Top Level Driver code.
index bfaa141573ee7fb1500343131f80062fe6abb581..c08f97e640944fc5b2028f46d04dd35a3218a541 100644 (file)
@@ -16,6 +16,7 @@
 
 namespace clang {
   class ASTContext;
+  class TranslationUnit;
   class Decl;
   class TagDecl;
   class HandleTagDeclDefinition;
@@ -31,6 +32,8 @@ public:
   /// ASTContext.
   virtual void Initialize(ASTContext &Context) {}
   
+  virtual void InitializeTU(TranslationUnit& TU);
+  
   /// HandleTopLevelDecl - Handle the specified top-level declaration.  This is
   ///  called by HandleTopLevelDeclaration to process every top-level Decl*.
   virtual void HandleTopLevelDecl(Decl *D) {}
index b3d12710927a8014754b094ae94edbcb3610f297..3f92990f36093e694e764da3a60361c0aea08415 100644 (file)
@@ -13,6 +13,8 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/TranslationUnit.h"
+
 using namespace clang;
 
 ASTConsumer::~ASTConsumer() {}
@@ -26,3 +28,7 @@ void ASTConsumer::HandleTopLevelDeclaration(Decl* d) {
   else
     HandleTopLevelDecl(d);
 }
+
+void ASTConsumer::InitializeTU(TranslationUnit& TU) {
+  Initialize(TU.getContext());
+}
index cff3ef7612e82d27c30c329e3917ba0cf6d541bf..9199179af74dac48ec1cba3f1c7a701fafd4e84f 100644 (file)
@@ -46,7 +46,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
   // Initialize the parser.
   P.Initialize();
   
-  Consumer->Initialize(Context);
+  Consumer->InitializeTU(TU);
   
   Parser::DeclTy *ADecl;