[clang] a16d33e - [clang][Interp][NFC] Don't invoke block dtor on uninitialized globals

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 5 04:57:37 PDT 2024


Author: Timm Bäder
Date: 2024-06-05T13:57:23+02:00
New Revision: a16d33eaebb3fdbc9435c125c206372c8a7374d5

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

LOG: [clang][Interp][NFC] Don't invoke block dtor on uninitialized globals

That can't ever work.

Added: 
    

Modified: 
    clang/lib/AST/Interp/Program.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Program.h b/clang/lib/AST/Interp/Program.h
index 36b5a1faa513a..ec7c0744b8856 100644
--- a/clang/lib/AST/Interp/Program.h
+++ b/clang/lib/AST/Interp/Program.h
@@ -45,7 +45,8 @@ class Program final {
     // but primitive arrays might have an InitMap* heap allocated and
     // that needs to be freed.
     for (Global *G : Globals)
-      G->block()->invokeDtor();
+      if (Block *B = G->block(); B->isInitialized())
+        B->invokeDtor();
 
     // Records might actually allocate memory themselves, but they
     // are allocated using a BumpPtrAllocator. Call their desctructors


        


More information about the cfe-commits mailing list