https://github.com/Ankur-0429 created 
https://github.com/llvm/llvm-project/pull/136807

#136055 

This PR adds basic support for enum declarations in CIR by handling the 
Decl::Enum case in CIRGenModule::emitTopLevelDecl(). The implementation 
currently asserts when debug info generation is requested.

A simple test case with an anonymous enum declaration has been added to verify 
the functionality.


>From 44a384b8ad774939c7664c8a476e852f1d4a7341 Mon Sep 17 00:00:00 2001
From: Ankur Ahir <ankura...@google.com>
Date: Tue, 22 Apr 2025 20:04:34 -0700
Subject: [PATCH] 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

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to