[Lldb-commits] [lldb] [lldb][TypeSystemClang] Simplify TypeSystemClang::IsEnumerationType implementation (PR #175560)

2026-01-12 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/175560

>From 58913ac2ad80319bda04d915f708e5b435af96db Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 12 Jan 2026 15:06:56 +
Subject: [PATCH] [lldb][TypeSystemClang] Simplify
 TypeSystemClang::IsEnumerationType implementation

We were calling into `IsIntegerType` to determine the signedness of the enum. 
Calling the relevant `clang::Type` API is simpler.

This shouldn't have any observable behaviour change.

We were lacking unit-test coverage for this. Added some tests that pass
before and after this change.
---
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  6 +-
 lldb/unittests/Symbol/TestTypeSystemClang.cpp | 58 +++
 2 files changed, 59 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3bb3bf3a8d127..027ca9441dfa9 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3310,11 +3310,7 @@ bool 
TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 GetCanonicalQualType(type)->getCanonicalTypeInternal());
 
 if (enum_type) {
-  IsIntegerType(enum_type->getDecl()
-->getDefinitionOrSelf()
-->getIntegerType()
-.getAsOpaquePtr(),
-is_signed);
+  is_signed = enum_type->isSignedIntegerOrEnumerationType();
   return true;
 }
   }
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp 
b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 155fc743934c2..f0dbf8919e07b 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -420,6 +420,64 @@ TEST_F(TestTypeSystemClang, TestEnumerationValueSign) {
   EXPECT_TRUE(enum_decl->getInitVal().isSigned());
 }
 
+TEST_F(TestTypeSystemClang, TestIsEnumerationType) {
+  auto holder =
+  std::make_unique("enum_ast");
+  auto &ast = *holder->GetAST();
+
+  // Scoped signed enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"scoped_signed_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeLong), /*is_scoped=*/true);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_TRUE(is_signed);
+  }
+
+  // Scoped unsigned enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"scoped_unsigned_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeUnsignedInt), /*is_scoped=*/true);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_FALSE(is_signed);
+  }
+
+  // Unscoped signed enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"unscoped_signed_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeLong), /*is_scoped=*/false);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_TRUE(is_signed);
+  }
+
+  // Unscoped unsigned enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"unscoped_unsigned_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeUnsignedInt), /*is_scoped=*/false);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_FALSE(is_signed);
+  }
+}
+
 TEST_F(TestTypeSystemClang, TestOwningModule) {
   auto holder =
   std::make_unique("module_ast");

___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Simplify TypeSystemClang::IsEnumerationType implementation (PR #175560)

2026-01-12 Thread via lldb-commits

github-actions[bot] wrote:


# :penguin: Linux x64 Test Results

The build failed before running any tests. Click on a failure below to see the 
details.


tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o

```
FAILED: 
tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
sccache /opt/llvm/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GLIBCXX_USE_CXX11_ABI=1 -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb/source/Plugins/TypeSystem/Clang
 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang
 -I/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/include 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb/include
 -I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/include 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/include 
-I/usr/include/python3.12 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/../clang/include
 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb/../clang/include
 -I/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source 
-I/home/gha/actions-runner/_work/llvm-project/llvm-project/build/tools/lldb/source
 -gmlt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wno-pass-failed -Wmisleading-indentation -Wctad-maybe-unsupported 
-fdiagnostics-color -ffunction-sections -fdata-sections -Wno-unknown-pragmas 
-Wno-strict-aliasing -Wno-vla-extension -O3 -DNDEBUG -std=c++17 -UNDEBUG 
-fno-exceptions -funwind-tables -fno-rtti -MD -MT 
tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
 -MF 
tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o.d
 -o 
tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o
 -c 
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3321:40:
 error: function definition is not allowed here
3321 | lldb::opaque_compiler_type_t type) {
|^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3335:65:
 error: function definition is not allowed here
3335 | CompilerType *pointee_type) {
| ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3388:68:
 error: function definition is not allowed here
3388 | lldb::opaque_compiler_type_t type, CompilerType *pointee_type) {
|^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3456:56:
 error: function definition is not allowed here
3456 |   bool *is_rvalue) {
|^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3491:61:
 error: function definition is not allowed here
3491 |   bool &is_complex) {
| ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3524:68:
 error: function definition is not allowed here
3524 | bool TypeSystemClang::IsDefined(lldb::opaque_compiler_type_t type) {
|^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3549:65:
 error: function definition is not allowed here
3549 | bool TypeSystemClang::IsObjCClassType(const CompilerType &type) {
| ^
/home/gha/actions-runner/_work/llvm-project/llvm-project/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:3562:77:
 error: function definition is not allowed here
3562 | bool TypeSystemClang::IsObjCObjectOrInterfaceType(const CompilerType 
&type) {
|

[Lldb-commits] [lldb] [lldb][TypeSystemClang] Simplify TypeSystemClang::IsEnumerationType implementation (PR #175560)

2026-01-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)


Changes

We were calling into `IsIntegerType` to determine the signedness of the enum. 
Calling the relevant `clang::Type` API is simpler.

This shouldn't have any observable behaviour change.

We were lacking unit-test coverage for this. Added some tests that pass before 
and after this change.

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


2 Files Affected:

- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+1-6) 
- (modified) lldb/unittests/Symbol/TestTypeSystemClang.cpp (+58) 


``diff
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3bb3bf3a8d127..29ed73bdd42e1 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3310,14 +3310,9 @@ bool 
TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 GetCanonicalQualType(type)->getCanonicalTypeInternal());
 
 if (enum_type) {
-  IsIntegerType(enum_type->getDecl()
-->getDefinitionOrSelf()
-->getIntegerType()
-.getAsOpaquePtr(),
-is_signed);
+  is_signed = enum_type->isSignedIntegerOrEnumerationType();
   return true;
 }
-  }
 
   return false;
 }
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp 
b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 155fc743934c2..f0dbf8919e07b 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -420,6 +420,64 @@ TEST_F(TestTypeSystemClang, TestEnumerationValueSign) {
   EXPECT_TRUE(enum_decl->getInitVal().isSigned());
 }
 
+TEST_F(TestTypeSystemClang, TestIsEnumerationType) {
+  auto holder =
+  std::make_unique("enum_ast");
+  auto &ast = *holder->GetAST();
+
+  // Scoped signed enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"scoped_signed_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeLong), /*is_scoped=*/true);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_TRUE(is_signed);
+  }
+
+  // Scoped unsigned enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"scoped_unsigned_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeUnsignedInt), /*is_scoped=*/true);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_FALSE(is_signed);
+  }
+
+  // Unscoped signed enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"unscoped_signed_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeLong), /*is_scoped=*/false);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_TRUE(is_signed);
+  }
+
+  // Unscoped unsigned enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"unscoped_unsigned_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeUnsignedInt), /*is_scoped=*/false);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_FALSE(is_signed);
+  }
+}
+
 TEST_F(TestTypeSystemClang, TestOwningModule) {
   auto holder =
   std::make_unique("module_ast");

``




https://github.com/llvm/llvm-project/pull/175560
___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][TypeSystemClang] Simplify TypeSystemClang::IsEnumerationType implementation (PR #175560)

2026-01-12 Thread Michael Buch via lldb-commits

https://github.com/Michael137 created 
https://github.com/llvm/llvm-project/pull/175560

We were calling into `IsIntegerType` to determine the signedness of the enum. 
Calling the relevant `clang::Type` API is simpler.

This shouldn't have any observable behaviour change.

We were lacking unit-test coverage for this. Added some tests that pass before 
and after this change.

>From e37ce6fdc42bc320f2df8a7501ca4529bff10bd8 Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 12 Jan 2026 15:06:56 +
Subject: [PATCH] [lldb][TypeSystemClang] Simplify
 TypeSystemClang::IsEnumerationType implementation

We were calling into `IsIntegerType` to determine the signedness of the enum. 
Calling the relevant `clang::Type` API is simpler.

This shouldn't have any observable behaviour change.

We were lacking unit-test coverage for this. Added some tests that pass
before and after this change.
---
 .../TypeSystem/Clang/TypeSystemClang.cpp  |  7 +--
 lldb/unittests/Symbol/TestTypeSystemClang.cpp | 58 +++
 2 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3bb3bf3a8d127..29ed73bdd42e1 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -3310,14 +3310,9 @@ bool 
TypeSystemClang::IsEnumerationType(lldb::opaque_compiler_type_t type,
 GetCanonicalQualType(type)->getCanonicalTypeInternal());
 
 if (enum_type) {
-  IsIntegerType(enum_type->getDecl()
-->getDefinitionOrSelf()
-->getIntegerType()
-.getAsOpaquePtr(),
-is_signed);
+  is_signed = enum_type->isSignedIntegerOrEnumerationType();
   return true;
 }
-  }
 
   return false;
 }
diff --git a/lldb/unittests/Symbol/TestTypeSystemClang.cpp 
b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
index 155fc743934c2..f0dbf8919e07b 100644
--- a/lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ b/lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -420,6 +420,64 @@ TEST_F(TestTypeSystemClang, TestEnumerationValueSign) {
   EXPECT_TRUE(enum_decl->getInitVal().isSigned());
 }
 
+TEST_F(TestTypeSystemClang, TestIsEnumerationType) {
+  auto holder =
+  std::make_unique("enum_ast");
+  auto &ast = *holder->GetAST();
+
+  // Scoped signed enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"scoped_signed_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeLong), /*is_scoped=*/true);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_TRUE(is_signed);
+  }
+
+  // Scoped unsigned enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"scoped_unsigned_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeUnsignedInt), /*is_scoped=*/true);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_FALSE(is_signed);
+  }
+
+  // Unscoped signed enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"unscoped_signed_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeLong), /*is_scoped=*/false);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_TRUE(is_signed);
+  }
+
+  // Unscoped unsigned enum
+  {
+CompilerType enum_type = ast.CreateEnumerationType(
+"unscoped_unsigned_enum", ast.GetTranslationUnitDecl(),
+OptionalClangModuleID(), Declaration(),
+ast.GetBasicType(eBasicTypeUnsignedInt), /*is_scoped=*/false);
+ASSERT_TRUE(enum_type);
+
+bool is_signed;
+EXPECT_TRUE(enum_type.IsEnumerationType(is_signed));
+EXPECT_FALSE(is_signed);
+  }
+}
+
 TEST_F(TestTypeSystemClang, TestOwningModule) {
   auto holder =
   std::make_unique("module_ast");

___
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits