diff options
-rw-r--r-- | tools/clang-cc/clang-cc.cpp | 12 |
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(); |