diff options
author | Manman Ren <manman.ren@gmail.com> | 2016-01-28 23:29:02 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2016-01-28 23:29:02 +0000 |
commit | 581c2b9d4615ca1e8da239b0a193959e067b18d9 (patch) | |
tree | ab6adae537488ac35cdf945e9211740491f81871 /clang/lib/CodeGen/ModuleBuilder.cpp | |
parent | 243d024a4bcb34edeaf6a5c866bae850519ee290 (diff) | |
download | bcm5719-llvm-581c2b9d4615ca1e8da239b0a193959e067b18d9.tar.gz bcm5719-llvm-581c2b9d4615ca1e8da239b0a193959e067b18d9.zip |
Check for frontend errors after releasing the Builder.
Frontend can emit errors when releaseing the Builder. If there are errors before
or when releasing the Builder, we reset the module to stop here before invoking
the backend.
Before this commit, clang will continue to invoke the backend and backend can
crash.
Differential Revision: http://reviews.llvm.org/D16564
llvm-svn: 259116
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 9428bdf1db3..234a7736065 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 { |