[clang] c444a01 - fixe leak found by asan build bot

via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 19 12:12:18 PST 2019


Author: Tyker
Date: 2019-11-19T21:11:37+01:00
New Revision: c444a01df3553d9405cbd4dac3c1074a71e6c2e1

URL: https://github.com/llvm/llvm-project/commit/c444a01df3553d9405cbd4dac3c1074a71e6c2e1
DIFF: https://github.com/llvm/llvm-project/commit/c444a01df3553d9405cbd4dac3c1074a71e6c2e1.diff

LOG: fixe leak found by asan build bot

Added: 
    

Modified: 
    clang/lib/AST/DeclCXX.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index bca560c40aef..6908b6a2b0a9 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2818,8 +2818,10 @@ StorageDuration LifetimeExtendedTemporaryDecl::getStorageDuration() const {
 APValue *LifetimeExtendedTemporaryDecl::getOrCreateValue(bool MayCreate) const {
   assert(getStorageDuration() == SD_Static &&
          "don't need to cache the computed value for this temporary");
-  if (MayCreate && !Value)
+  if (MayCreate && !Value) {
     Value = (new (getASTContext()) APValue);
+    getASTContext().addDestruction(Value);
+  }
   assert(Value && "may not be null");
   return Value;
 }


        


More information about the cfe-commits mailing list