[clang] 8f08b75 - [Clang] Assert non-null enum definition in CGDebugInfo::CreateTypeDefinition(const EnumType*) (#105556)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 23 11:23:28 PDT 2024


Author: smanna12
Date: 2024-08-23T13:23:25-05:00
New Revision: 8f08b75ce4af9dc72fb560033db14891ac01a682

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

LOG: [Clang] Assert non-null enum definition in CGDebugInfo::CreateTypeDefinition(const EnumType*) (#105556)

This commit adds an assert to check for a non-null enum definition in
CGDebugInfo::CreateTypeDefinition(const EnumType*), ensuring
precondition validity.

Previous discussion on https://github.com/llvm/llvm-project/pull/97105

Added: 
    

Modified: 
    clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7ad3088f0ab756..dc83d596e3cb06 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3561,6 +3561,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
 
   SmallVector<llvm::Metadata *, 16> Enumerators;
   ED = ED->getDefinition();
+  assert(ED && "An enumeration definition is required");
   for (const auto *Enum : ED->enumerators()) {
     Enumerators.push_back(
         DBuilder.createEnumerator(Enum->getName(), Enum->getInitVal()));


        


More information about the cfe-commits mailing list