aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-07-29 02:40:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-07-29 02:40:09 +0000
commit70186ab134119fbec816a02596e29fb4cfbe51e1 (patch)
treed777d744ae0687131501f19a6753a53cec32252a
parent1d2154c3590d21345d02e28f2916f7492c82bf54 (diff)
Destroy the ASTConsumer prior to the Context, HTMLPrinter for example wants to
do a significant amount of work in its destructor, which may access the context. (PR4642). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77423 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/clang-cc/clang-cc.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index bb18a998b2..ab4bb1eff4 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -2078,6 +2078,13 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
if (FixItRewrite)
FixItRewrite->WriteFixedFile(InFile, OutputFile);
+
+ // Disable the consumer prior to the context, the consumer may perform actions
+ // in its destructor which require the context.
+ if (DisableFree)
+ Consumer.take();
+ else
+ Consumer.reset();
// If in -disable-free mode, don't deallocate ASTContext.
if (DisableFree)
@@ -2104,11 +2111,6 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
if (ClearSourceMgr)
PP.getSourceManager().clearIDTables();
- if (DisableFree)
- Consumer.take();
- else
- Consumer.reset();
-
// Always delete the output stream because we don't want to leak file
// handles. Also, we don't want to try to erase an open file.
OS.reset();