[Lldb-commits] [lldb] 3134b9f - [lldb][TypeSystemClang] Fix nullptr check when creating enumerator decls

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 8 01:39:42 PST 2026


Author: Michael Buch
Date: 2026-01-08T09:39:24Z
New Revision: 3134b9fbc5c1ec9a653684228e1ca547b3a29a77

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

LOG: [lldb][TypeSystemClang] Fix nullptr check when creating enumerator decls

There is no point in checking the `enumerator_decl` because it was just created with `CreateDeserialized` above (which would only fail if allocation failed, but we don't do those checks usually). We dereference it unconditionally above this check anyway.

What this intended to check was probably `enum_decl`, because we derefernce it for the first time right after the check. This patch changes the nullptr check to `enum_decl`.

No test coverage because this should be pretty uncontroversial.

Note, I just saw this while auditing the code, I didn't actually run into a crash.

Added: 
    

Modified: 
    lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 89c860878622c..1e1b265ba195a 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -8597,7 +8597,7 @@ clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
   enumerator_decl->setAccess(AS_public);
   SetMemberOwningModule(enumerator_decl, enum_decl);
 
-  if (!enumerator_decl)
+  if (!enum_decl)
     return nullptr;
 
   enum_decl->addDecl(enumerator_decl);


        


More information about the lldb-commits mailing list