diff options
Diffstat (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp')
-rw-r--r-- | clang/lib/CodeGen/ModuleBuilder.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index 9428bdf..234a773 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -199,15 +199,18 @@ namespace { } void HandleTranslationUnit(ASTContext &Ctx) override { + // Release the Builder when there is no error. + if (!Diags.hasErrorOccurred() && Builder) + Builder->Release(); + + // If there are errors before or when releasing the Builder, reset + // the module to stop here before invoking the backend. if (Diags.hasErrorOccurred()) { if (Builder) Builder->clear(); M.reset(); return; } - - if (Builder) - Builder->Release(); } void AssignInheritanceModel(CXXRecordDecl *RD) override { |