[clang] [CIR] Upstream enum support (PR #136807)
Ankur Ahir via cfe-commits
cfe-commits at lists.llvm.org
Fri May 2 18:30:00 PDT 2025
https://github.com/Ankur-0429 updated https://github.com/llvm/llvm-project/pull/136807
>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH 01/14] Upstream enum support
---
clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 +++
clang/test/CIR/CodeGen/basic.c | 5 +++++
clang/test/CIR/CodeGen/basic.cpp | 5 +++++
3 files changed, 13 insertions(+)
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 3b13d495be5e3..79db25dda3fea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -617,6 +617,9 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
case Decl::OpenACCDeclare:
emitGlobalOpenACCDecl(cast<OpenACCDeclareDecl>(decl));
break;
+ case Decl::Enum:
+ assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
+ break;
case Decl::Typedef:
case Decl::TypeAlias: // using foo = bar; [C++11]
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 1845d3b64bf68..623aad778f0db 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -253,3 +253,8 @@ size_type max_size(void) {
// OGCG: define{{.*}} i64 @max_size()
// OGCG: ret i64 2305843009213693951
+
+enum {
+ um = 0,
+ dois = 1,
+};
\ No newline at end of file
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 0f8431325a86f..c1c3e60079869 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,3 +102,8 @@ size_type max_size() {
// CHECK: %3 = cir.cast(integral, %2 : !s32i), !u64i
// CHECK: %4 = cir.const #cir.int<8> : !u64i
// CHECK: %5 = cir.binop(div, %3, %4) : !u64i
+
+enum {
+ um = 0,
+ dois = 1,
+};
\ No newline at end of file
>From 83240e84668fcef9dda04ac64d8c3b294a02e2ea Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Wed, 23 Apr 2025 19:12:12 -0700
Subject: [PATCH 02/14] resolving
https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056609689
---
clang/lib/CIR/CodeGen/CIRGenModule.cpp | 3 ---
1 file changed, 3 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 79db25dda3fea..f560692b705ab 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -618,9 +618,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
emitGlobalOpenACCDecl(cast<OpenACCDeclareDecl>(decl));
break;
case Decl::Enum:
- assert(!cir::MissingFeatures::generateDebugInfo() && "NYI");
- break;
-
case Decl::Typedef:
case Decl::TypeAlias: // using foo = bar; [C++11]
case Decl::Record:
>From e431b59ebf0d7702c8b66658b3fccedf411eb2bd Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Wed, 23 Apr 2025 19:14:13 -0700
Subject: [PATCH 03/14] resolving
https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056780889
---
clang/test/CIR/CodeGen/basic.c | 2 +-
clang/test/CIR/CodeGen/basic.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 623aad778f0db..ccfa10412c2bc 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -257,4 +257,4 @@ size_type max_size(void) {
enum {
um = 0,
dois = 1,
-};
\ No newline at end of file
+};
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index c1c3e60079869..55735680991c9 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -106,4 +106,4 @@ size_type max_size() {
enum {
um = 0,
dois = 1,
-};
\ No newline at end of file
+};
>From f078a1c145922596eccfc89cd4c701a711772d2a Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Wed, 23 Apr 2025 20:37:54 -0700
Subject: [PATCH 04/14] resolving
https://github.com/llvm/llvm-project/pull/136807\#discussion_r2056613948
---
clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 7 +++++++
clang/test/CIR/CodeGen/basic.c | 15 ++++++++++++---
clang/test/CIR/CodeGen/basic.cpp | 14 +++++++++++---
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index b11f8466607f8..130b3107153ea 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -399,6 +399,13 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
break;
}
+ case Type::Enum: {
+ const EnumDecl *ED = cast<EnumType>(ty)->getDecl();
+ if (ED->isCompleteDefinition() || ED->isFixed())
+ return convertType(ED->getIntegerType());
+ break;
+ }
+
case Type::FunctionNoProto:
case Type::FunctionProto:
resultType = convertFunctionTypeInternal(type);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index ccfa10412c2bc..b02e25bf43f74 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -254,7 +254,16 @@ size_type max_size(void) {
// OGCG: define{{.*}} i64 @max_size()
// OGCG: ret i64 2305843009213693951
-enum {
- um = 0,
- dois = 1,
+enum A {
+ A_one,
+ A_two
};
+enum A a;
+
+// CHECK: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
+// CHECK: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
+// CHECK: cir.return %6 : !u64i
+// CHECK: }
+// CHECK: cir.global external @a = #cir.int<0> : !u32i
+// CHECK: }
+
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 55735680991c9..238239ab5d626 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -103,7 +103,15 @@ size_type max_size() {
// CHECK: %4 = cir.const #cir.int<8> : !u64i
// CHECK: %5 = cir.binop(div, %3, %4) : !u64i
-enum {
- um = 0,
- dois = 1,
+enum A {
+ A_one,
+ A_two
};
+A a;
+
+// CHECK: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
+// CHECK: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
+// CHECK: cir.return %6 : !u64i
+// CHECK: }
+// CHECK: cir.global external @a = #cir.int<0> : !u32i
+// CHECK: }
>From 0854b2ffaffef5171d65e37dcf87e56e86aeb38b Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Wed, 23 Apr 2025 20:45:13 -0700
Subject: [PATCH 05/14] added default resulttype to enum decl
---
clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index 130b3107153ea..c3f044731fa48 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -403,6 +403,7 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
const EnumDecl *ED = cast<EnumType>(ty)->getDecl();
if (ED->isCompleteDefinition() || ED->isFixed())
return convertType(ED->getIntegerType());
+ resultType = cgm.UInt32Ty;
break;
}
>From 8d6a14326f57fc4dbc0964567161531eceb855c0 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Wed, 23 Apr 2025 20:48:31 -0700
Subject: [PATCH 06/14] small formatting for basic.c
---
clang/test/CIR/CodeGen/basic.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index b02e25bf43f74..b90c2c52f1267 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -266,4 +266,3 @@ enum A a;
// CHECK: }
// CHECK: cir.global external @a = #cir.int<0> : !u32i
// CHECK: }
-
>From 4f9c7d36b7945d03ea26cec90993b8d4d8ae463f Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Fri, 25 Apr 2025 23:38:55 -0700
Subject: [PATCH 07/14] small formatting for cirgenmodule.cpp
---
clang/lib/CIR/CodeGen/CIRGenModule.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index 0583523f76958..e8a214896c0cb 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -668,7 +668,6 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
emitGlobalOpenACCDecl(cast<OpenACCDeclareDecl>(decl));
break;
case Decl::Enum:
-
case Decl::UsingDirective: // using namespace X; [C++]
case Decl::Typedef:
case Decl::TypeAlias: // using foo = bar; [C++11]
>From 29c354c998a09b5f856cc28ac2f303a138480880 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Sat, 26 Apr 2025 00:15:57 -0700
Subject: [PATCH 08/14] Adding test case for enum E : int;
---
clang/test/CIR/CodeGen/basic.c | 4 ++++
clang/test/CIR/CodeGen/basic.cpp | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index b90c2c52f1267..6a7b9f4c62bad 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -266,3 +266,7 @@ enum A a;
// CHECK: }
// CHECK: cir.global external @a = #cir.int<0> : !u32i
// CHECK: }
+
+enum E : int;
+
+// CHECK-NOT: cir.global {{.*}} @E
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 77b344d16bbe9..7bc6e52a1ffda 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -115,3 +115,7 @@ A a;
// CHECK: }
// CHECK: cir.global external @a = #cir.int<0> : !u32i
// CHECK: }
+
+enum E : int;
+
+// CHECK-NOT: cir.global {{.*}} @E
>From 9d51df49d2b9f36eaf1e95d446b72fc18de28b6d Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Sat, 26 Apr 2025 00:38:17 -0700
Subject: [PATCH 09/14] Refactor enums in basic.c and basic.cpp; replace enum E
with enum B and add enum Case
---
clang/test/CIR/CodeGen/basic.c | 25 +++++++++++++++++--------
clang/test/CIR/CodeGen/basic.cpp | 22 +++++++++++++++-------
2 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 6a7b9f4c62bad..4d02b3c478b38 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -247,6 +247,10 @@ size_type max_size(void) {
// CIR: %3 = cir.cast(integral, %2 : !s32i), !u64i
// CIR: %4 = cir.const #cir.int<8> : !u64i
// CIR: %5 = cir.binop(div, %3, %4) : !u64i
+// CIR: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
+// CIR: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
+// CIR: cir.return %6 : !u64i
+// CIR: }
// LLVM: define i64 @max_size()
// LLVM: store i64 2305843009213693951, ptr
@@ -260,13 +264,18 @@ enum A {
};
enum A a;
-// CHECK: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
-// CHECK: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
-// CHECK: cir.return %6 : !u64i
-// CHECK: }
-// CHECK: cir.global external @a = #cir.int<0> : !u32i
-// CHECK: }
+// CIR: cir.global external @a = #cir.int<0> : !u32i
-enum E : int;
+enum B : int;
+enum B b;
+
+// CIR: cir.global external @b = #cir.int<0> : !s32i
+
+enum C : int {
+ C_one,
+ C_two
+};
+enum C c;
+
+// CIR: cir.global external @c = #cir.int<0> : !s32i
-// CHECK-NOT: cir.global {{.*}} @E
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 7bc6e52a1ffda..86187a00f47b4 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -102,6 +102,10 @@ size_type max_size() {
// CHECK: %3 = cir.cast(integral, %2 : !s32i), !u64i
// CHECK: %4 = cir.const #cir.int<8> : !u64i
// CHECK: %5 = cir.binop(div, %3, %4) : !u64i
+// CHECK: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
+// CHECK: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
+// CHECK: cir.return %6 : !u64i
+// CHECK: }
enum A {
A_one,
@@ -109,13 +113,17 @@ enum A {
};
A a;
-// CHECK: cir.store %5, %0 : !u64i, !cir.ptr<!u64i>
-// CHECK: %6 = cir.load %0 : !cir.ptr<!u64i>, !u64i
-// CHECK: cir.return %6 : !u64i
-// CHECK: }
// CHECK: cir.global external @a = #cir.int<0> : !u32i
-// CHECK: }
-enum E : int;
+enum B : int;
+B b;
+
+// CHECK: cir.global external @b = #cir.int<0> : !s32i
+
+enum C : int {
+ C_one,
+ C_two
+};
+C c;
-// CHECK-NOT: cir.global {{.*}} @E
+// CHECK: cir.global external @c = #cir.int<0> : !s32i
>From b67c744907bd2684f6c1c2cef2e664c6a36bad03 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Sat, 26 Apr 2025 00:40:46 -0700
Subject: [PATCH 10/14] added enum class case for basic.cpp
---
clang/test/CIR/CodeGen/basic.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 86187a00f47b4..084ad60deb796 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -127,3 +127,8 @@ enum C : int {
C c;
// CHECK: cir.global external @c = #cir.int<0> : !s32i
+
+enum class D : int;
+D d;
+
+// CHECK: cir.global external @d = #cir.int<0> : !s32i
\ No newline at end of file
>From a20bc6e675f31c356e9bae1263bcb2bcb2ddd620 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Sat, 26 Apr 2025 00:41:36 -0700
Subject: [PATCH 11/14] added new line to basic.cpp
---
clang/test/CIR/CodeGen/basic.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index 084ad60deb796..4aea771edef60 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -131,4 +131,4 @@ C c;
enum class D : int;
D d;
-// CHECK: cir.global external @d = #cir.int<0> : !s32i
\ No newline at end of file
+// CHECK: cir.global external @d = #cir.int<0> : !s32i
>From e8816eabb0a671eb5a526e9df23958d2205c3e71 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Thu, 1 May 2025 19:43:53 -0700
Subject: [PATCH 12/14] resolving
https://github.com/llvm/llvm-project/pull/136807\#discussion_r2067667188
---
clang/include/clang/CIR/MissingFeatures.h | 1 +
clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/clang/include/clang/CIR/MissingFeatures.h b/clang/include/clang/CIR/MissingFeatures.h
index bb5dac4faa1e0..23d0d77a64978 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -161,6 +161,7 @@ struct MissingFeatures {
static bool targetSpecificCXXABI() { return false; }
static bool moduleNameHash() { return false; }
static bool setDSOLocal() { return false; }
+ static bool updateCompletedType() { return false; }
// Missing types
static bool dataMemberType() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index f2812a77d2956..7595d3ee3d95f 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -408,9 +408,14 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
}
case Type::Enum: {
+ // TODO(cir): Implement updateCompletedType for enums.
+ assert(!cir.MissingFeatures::updateCompletedType());
const EnumDecl *ED = cast<EnumType>(ty)->getDecl();
if (ED->isCompleteDefinition() || ED->isFixed())
return convertType(ED->getIntegerType());
+ // Return a placeholder 'i32' type. This can be changed later when the
+ // type is defined (see UpdateCompletedType), but is likely to be the
+ // "right" answer.
resultType = cgm.UInt32Ty;
break;
}
>From 7fd353d27ad65eb4744d81579e1bd20c6b9b2bd6 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <69181589+Ankur-0429 at users.noreply.github.com>
Date: Fri, 2 May 2025 17:50:48 -0700
Subject: [PATCH 13/14] Update clang/lib/CIR/CodeGen/CIRGenTypes.cpp
Co-authored-by: Morris Hafner <mmha at users.noreply.github.com>
---
clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index c740bc90f6f4f..f024dbb282f6e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -421,8 +421,8 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
// TODO(cir): Implement updateCompletedType for enums.
assert(!cir.MissingFeatures::updateCompletedType());
const EnumDecl *ED = cast<EnumType>(ty)->getDecl();
- if (ED->isCompleteDefinition() || ED->isFixed())
- return convertType(ED->getIntegerType());
+ if (auto integerType = ED->getIntegerType(); !integerType.isNull())
+ return convertType(integerType);
// Return a placeholder 'i32' type. This can be changed later when the
// type is defined (see UpdateCompletedType), but is likely to be the
// "right" answer.
>From 807e46521ffe745cf736e4b3d4a312cddcc35fa8 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankurahir at google.com>
Date: Fri, 2 May 2025 18:29:41 -0700
Subject: [PATCH 14/14] resolving
https://github.com/llvm/llvm-project/pull/136807\#discussion_r2072091421
---
clang/lib/CIR/CodeGen/CIRGenTypes.cpp | 2 +-
clang/test/CIR/CodeGen/basic.c | 7 +++++++
clang/test/CIR/CodeGen/basic.cpp | 7 +++++++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
index f024dbb282f6e..e6579d93c527c 100644
--- a/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenTypes.cpp
@@ -419,7 +419,7 @@ mlir::Type CIRGenTypes::convertType(QualType type) {
case Type::Enum: {
// TODO(cir): Implement updateCompletedType for enums.
- assert(!cir.MissingFeatures::updateCompletedType());
+ assert(!cir::MissingFeatures::updateCompletedType());
const EnumDecl *ED = cast<EnumType>(ty)->getDecl();
if (auto integerType = ED->getIntegerType(); !integerType.isNull())
return convertType(integerType);
diff --git a/clang/test/CIR/CodeGen/basic.c b/clang/test/CIR/CodeGen/basic.c
index 4d02b3c478b38..f191a07fda96c 100644
--- a/clang/test/CIR/CodeGen/basic.c
+++ b/clang/test/CIR/CodeGen/basic.c
@@ -279,3 +279,10 @@ enum C c;
// CIR: cir.global external @c = #cir.int<0> : !s32i
+enum D {
+ D_one = -1
+};
+enum D d;
+
+// CIR: cir.global external @d = #cir.int<0> : !s32i
+
diff --git a/clang/test/CIR/CodeGen/basic.cpp b/clang/test/CIR/CodeGen/basic.cpp
index d7068c0ed3d77..07e10d619434e 100644
--- a/clang/test/CIR/CodeGen/basic.cpp
+++ b/clang/test/CIR/CodeGen/basic.cpp
@@ -133,6 +133,13 @@ D d;
// CHECK: cir.global external @d = #cir.int<0> : !s32i
+enum E {
+ D_one = -1
+};
+enum E e;
+
+// CHECK: cir.global external @e = #cir.int<0> : !s32i
+
void ref_arg(int &x) {
int y = x;
x = 3;
More information about the cfe-commits
mailing list