]> granicus.if.org Git - clang/commitdiff
If any errors have occurred by the time we hit the end of a function body, clear...
authorDouglas Gregor <dgregor@apple.com>
Sun, 15 Nov 2009 07:07:58 +0000 (07:07 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 15 Nov 2009 07:07:58 +0000 (07:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88834 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index 65e839b04db93699490b8eebdac52cf9e2d95c61..34e9acb9adb3e10f1b339ef8049e31a2ddfcc13c 100644 (file)
@@ -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;
 }