[clang] [CIR] Add handlers for 'using enum' and namespace alias (PR #148011)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 10 10:47:45 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clangir
Author: Andy Kaylor (andykaylor)
<details>
<summary>Changes</summary>
These decl types don't require any code generation, though when debug info is implemented, we will need to add handling for that. Until then, we just need to have a handler so they don't generate an NYI error.
---
Full diff: https://github.com/llvm/llvm-project/pull/148011.diff
3 Files Affected:
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+2)
- (modified) clang/test/CIR/CodeGen/enum.cpp (+11)
- (modified) clang/test/CIR/CodeGen/namespace.cpp (+8)
``````````diff
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index c1434ee697f4c..8b2883b50d2e2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -1258,6 +1258,8 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
case Decl::Enum:
case Decl::Using: // using X; [C++]
case Decl::UsingDirective: // using namespace X; [C++]
+ case Decl::UsingEnum: // using enum X; [C++]
+ case Decl::NamespaceAlias:
case Decl::Typedef:
case Decl::TypeAlias: // using foo = bar; [C++11]
case Decl::Record:
diff --git a/clang/test/CIR/CodeGen/enum.cpp b/clang/test/CIR/CodeGen/enum.cpp
index 5d9b1057aaa14..247fa0a3bfd43 100644
--- a/clang/test/CIR/CodeGen/enum.cpp
+++ b/clang/test/CIR/CodeGen/enum.cpp
@@ -14,3 +14,14 @@ int f() {
// CHECK: cir.func{{.*}} @_Z1fv
// CHECK: cir.const #cir.int<1> : !u32i
+
+namespace test {
+ using enum Numbers;
+};
+
+int f2() {
+ return test::Two;
+}
+
+// CHECK: cir.func{{.*}} @_Z2f2v
+// CHECK: cir.const #cir.int<2> : !u32i
diff --git a/clang/test/CIR/CodeGen/namespace.cpp b/clang/test/CIR/CodeGen/namespace.cpp
index efae1f2f2f236..4c7812c61bfe4 100644
--- a/clang/test/CIR/CodeGen/namespace.cpp
+++ b/clang/test/CIR/CodeGen/namespace.cpp
@@ -93,3 +93,11 @@ void f7() {
}
// CHECK: cir.func{{.*}} @_Z2f7v()
+
+namespace test_alias = test;
+
+int f8() {
+ return test_alias::g2;
+}
+
+// CHECK: cir.func{{.*}} @_Z2f8v()
``````````
</details>
https://github.com/llvm/llvm-project/pull/148011
More information about the cfe-commits
mailing list