Skip to content

[CIR] Add empty handlers for Using and UsingShadow decls #143032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,7 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
emitGlobalOpenACCDecl(cast<OpenACCDeclareDecl>(decl));
break;
case Decl::Enum:
case Decl::Using: // using X; [C++]
case Decl::UsingDirective: // using namespace X; [C++]
case Decl::Typedef:
case Decl::TypeAlias: // using foo = bar; [C++11]
Expand All @@ -1143,6 +1144,10 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
assert(!cir::MissingFeatures::generateDebugInfo());
break;

// No code generation needed.
case Decl::UsingShadow:
break;

// C++ Decls
case Decl::LinkageSpec:
case Decl::Namespace:
Expand Down
43 changes: 43 additions & 0 deletions clang/test/CIR/CodeGen/namespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,46 @@ int f4(void) {
// CHECK: %[[G3_ADDR:.*]] = cir.get_global @_ZN4test5test22g3E : !cir.ptr<!s32i>
// CHECK: %[[G3_VAL:.*]] = cir.load{{.*}} %[[G3_ADDR]] : !cir.ptr<!s32i>, !s32i
// CHECK: %[[SUM2:.*]] = cir.binop(add, %[[SUM]], %[[G3_VAL]]) nsw : !s32i

using test2::f3;
using test2::g3;

int f5() {
f3();
return g3;
}

// CHECK: cir.func @_Z2f5v()
// CHECK: cir.call @_ZN4test5test22f3Ev()
// CHECK: %[[G3_ADDR:.*]] = cir.get_global @_ZN4test5test22g3E : !cir.ptr<!s32i>
// CHECK: %[[G3_VAL:.*]] = cir.load{{.*}} %[[G3_ADDR]] : !cir.ptr<!s32i>, !s32i

namespace test3 {
struct S {
int a;
} s;
}

using test3::s;

int f6() {
return s.a;
}

// CHECK: cir.func @_Z2f6v()
// CHECK: cir.get_global @_ZN5test31sE : !cir.ptr<!rec_test33A3AS>
// CHECK: cir.get_member %{{.*}}[0] {name = "a"}

int shadowedFunc() {
return 3;
}

namespace shadow {
using ::shadowedFunc;
}

void f7() {
shadow::shadowedFunc();
}

// CHECK: cir.func @_Z2f7v()
Loading