[cfe-commits] r54486 - in /cfe/trunk: include/clang/Sema/ParseAST.h lib/CodeGen/ModuleBuilder.cpp lib/Sema/ParseAST.cpp

Ted Kremenek kremenek at apple.com
Thu Aug 7 12:47:43 PDT 2008


Author: kremenek
Date: Thu Aug  7 14:47:41 2008
New Revision: 54486

URL: http://llvm.org/viewvc/llvm-project?rev=54486&view=rev
Log:
ParseAST now conditionally deletes the passed ASTConsumer.
ModuleBuilder now performs llvmgen in HandleTranslationUnit.

This patch follows from the discussion on the following thread on cfe-commits:

http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20080804/006849.html


Modified:
    cfe/trunk/include/clang/Sema/ParseAST.h
    cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
    cfe/trunk/lib/Sema/ParseAST.cpp

Modified: cfe/trunk/include/clang/Sema/ParseAST.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParseAST.h?rev=54486&r1=54485&r2=54486&view=diff

==============================================================================
--- cfe/trunk/include/clang/Sema/ParseAST.h (original)
+++ cfe/trunk/include/clang/Sema/ParseAST.h Thu Aug  7 14:47:41 2008
@@ -21,7 +21,7 @@
   /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
   /// the file is parsed.  This takes ownership of the ASTConsumer and
   /// ultimately deletes it.
-  void ParseAST(Preprocessor &pp, ASTConsumer *C, bool PrintStats = false);
+  void ParseAST(Preprocessor &pp, ASTConsumer *C, bool PrintStats = false, bool DeleteConsumer = true);
 }  // end namespace clang
 
 #endif

Modified: cfe/trunk/lib/CodeGen/ModuleBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ModuleBuilder.cpp?rev=54486&r1=54485&r2=54486&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/ModuleBuilder.cpp (original)
+++ cfe/trunk/lib/CodeGen/ModuleBuilder.cpp Thu Aug  7 14:47:41 2008
@@ -49,13 +49,7 @@
     
     virtual ~CodeGeneratorImpl() {}
     
-    virtual llvm::Module* ReleaseModule() {      
-      if (Diags.hasErrorOccurred())
-        return 0;
-      
-      if (Builder)
-        Builder->Release();
-      
+    virtual llvm::Module* ReleaseModule() {
       return M.take();
     }
     
@@ -134,7 +128,16 @@
     virtual void HandleTagDeclDefinition(TagDecl *D) {
       Builder->UpdateCompletedType(D);
     }
-    
+
+    virtual void HandleTranslationUnit(TranslationUnit& TU) {
+      if (Diags.hasErrorOccurred()) {
+        M.reset();
+        return;
+      }
+
+      if (Builder)
+        Builder->Release();
+    };
   };
 }
 

Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=54486&r1=54485&r2=54486&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Thu Aug  7 14:47:41 2008
@@ -27,7 +27,7 @@
 /// ParseAST - Parse the entire file specified, notifying the ASTConsumer as
 /// the file is parsed.  This takes ownership of the ASTConsumer and
 /// ultimately deletes it.
-void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
+void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats, bool DeleteConsumer) {
   // Collect global stats on Decls/Stmts (until we have a module streamer).
   if (PrintStats) {
     Decl::CollectingStats(true);
@@ -78,5 +78,6 @@
     Stmt::CollectingStats(false);
   }
   
-  delete Consumer;
+  if (DeleteConsumer)
+    delete Consumer;
 }





More information about the cfe-commits mailing list