llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: None (smanna12)

<details>
<summary>Changes</summary>

This commit adds an assertion to the CreateTypeDefinition function in 
CGDebugInfo.cpp to verify that an enumeration definition (ED) is available 
before iterating over its enumerators. This prevents potential null pointer 
dereferences and ensures that the function operates on a valid enumeration 
definition.

---
Full diff: https://github.com/llvm/llvm-project/pull/105556.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1) 


``````````diff
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()));

``````````

</details>


https://github.com/llvm/llvm-project/pull/105556
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to