aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-08-07 19:47:41 +0000
committerTed Kremenek <kremenek@apple.com>2008-08-07 19:47:41 +0000
commit159346a82bfa5063ead81af903a2bc5e5a9e5b36 (patch)
tree08aaef7c78cd06cfd385666b4d2b02ec5d98c840 /lib
parent57134339c862673d0c4ff1fa7cb333915832e02a (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/ModuleBuilder.cpp19
-rw-r--r--lib/Sema/ParseAST.cpp5
2 files changed, 14 insertions, 10 deletions
diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp
index 7329ed1d90..6ce4e6894d 100644
--- a/lib/CodeGen/ModuleBuilder.cpp
+++ b/lib/CodeGen/ModuleBuilder.cpp
@@ -49,13 +49,7 @@ namespace {
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 @@ namespace {
virtual void HandleTagDeclDefinition(TagDecl *D) {
Builder->UpdateCompletedType(D);
}
-
+
+ virtual void HandleTranslationUnit(TranslationUnit& TU) {
+ if (Diags.hasErrorOccurred()) {
+ M.reset();
+ return;
+ }
+
+ if (Builder)
+ Builder->Release();
+ };
};
}
diff --git a/lib/Sema/ParseAST.cpp b/lib/Sema/ParseAST.cpp
index 94e0185f03..6b9b8d5804 100644
--- a/lib/Sema/ParseAST.cpp
+++ b/lib/Sema/ParseAST.cpp
@@ -27,7 +27,7 @@ using namespace clang;
/// 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 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, bool PrintStats) {
Stmt::CollectingStats(false);
}
- delete Consumer;
+ if (DeleteConsumer)
+ delete Consumer;
}