diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-15 07:07:58 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-15 07:07:58 +0000 |
commit | d5b57281cc3c652e9bbdbab45fbc199e29686377 (patch) | |
tree | c2051199d7eb04b2a62827c35dfdd3e227e80562 /lib/Sema/SemaDecl.cpp | |
parent | d58c03f42ebb4e548c2b53fa25b1cfe02ebb9ac0 (diff) |
If any errors have occurred by the time we hit the end of a function body, clear out any remaining temporaries so they aren't seen later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 65e839b04d..34e9acb9ad 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4026,6 +4026,12 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg, if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(dcl)) computeBaseOrMembersToDestroy(Destructor); + // If any errors have occurred, clear out any temporaries that may have + // been leftover. This ensures that these temporaries won't be picked up for + // deletion in some later function. + if (PP.getDiagnostics().hasErrorOccurred()) + ExprTemporaries.clear(); + assert(ExprTemporaries.empty() && "Leftover temporaries in function"); return D; } |