[clang] 58b9564 - [clang][Interp][NFC] Add some assertions

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Tue May 14 03:26:33 PDT 2024


Author: Timm Bäder
Date: 2024-05-14T12:26:04+02:00
New Revision: 58b9564d5d12063bb9c662039802ede8df615374

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

LOG: [clang][Interp][NFC] Add some assertions

Make sure we pass a non-null Descriptor when creating a new Block.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/InterpBlock.h b/clang/lib/AST/Interp/InterpBlock.h
index 6d5856fbd4ea1..506034e880d0b 100644
--- a/clang/lib/AST/Interp/InterpBlock.h
+++ b/clang/lib/AST/Interp/InterpBlock.h
@@ -51,11 +51,15 @@ class Block final {
   /// Creates a new block.
   Block(const std::optional<unsigned> &DeclID, const Descriptor *Desc,
         bool IsStatic = false, bool IsExtern = false)
-      : DeclID(DeclID), IsStatic(IsStatic), IsExtern(IsExtern), Desc(Desc) {}
+      : DeclID(DeclID), IsStatic(IsStatic), IsExtern(IsExtern), Desc(Desc) {
+        assert(Desc);
+      }
 
   Block(const Descriptor *Desc, bool IsStatic = false, bool IsExtern = false)
       : DeclID((unsigned)-1), IsStatic(IsStatic), IsExtern(IsExtern),
-        Desc(Desc) {}
+        Desc(Desc) {
+          assert(Desc);
+        }
 
   /// Returns the block's descriptor.
   const Descriptor *getDescriptor() const { return Desc; }


        


More information about the cfe-commits mailing list