Skip to content

Conversation

@andykaylor
Copy link
Contributor

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.

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.
@llvmbot llvmbot added clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project labels Jul 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)

Changes

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 --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()

@andykaylor andykaylor merged commit b415db0 into llvm:main Jul 10, 2025
12 checks passed
@andykaylor andykaylor deleted the cir-noop-decls branch July 10, 2025 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category ClangIR Anything related to the ClangIR project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants