Skip to content

Commit ca177a7

Browse files
andykaylorrorth
authored andcommitted
[CIR] Add empty handlers for Using and UsingShadow decls (llvm#143032)
This adds emitTopLevelDecl "handlers" for Using and UsingShadow. These don't actually need any handling, but they need to be present in the switch to avoid hitting the default handler, which issues a diagnostic about the decl kind not being implemented. There are several other decl kinds that don't need any handling. Those will be added when I have test cases for them.
1 parent 10dde13 commit ca177a7

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
11351135
emitGlobalOpenACCDecl(cast<OpenACCDeclareDecl>(decl));
11361136
break;
11371137
case Decl::Enum:
1138+
case Decl::Using: // using X; [C++]
11381139
case Decl::UsingDirective: // using namespace X; [C++]
11391140
case Decl::Typedef:
11401141
case Decl::TypeAlias: // using foo = bar; [C++11]
@@ -1143,6 +1144,10 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
11431144
assert(!cir::MissingFeatures::generateDebugInfo());
11441145
break;
11451146

1147+
// No code generation needed.
1148+
case Decl::UsingShadow:
1149+
break;
1150+
11461151
// C++ Decls
11471152
case Decl::LinkageSpec:
11481153
case Decl::Namespace:

clang/test/CIR/CodeGen/namespace.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,46 @@ int f4(void) {
5050
// CHECK: %[[G3_ADDR:.*]] = cir.get_global @_ZN4test5test22g3E : !cir.ptr<!s32i>
5151
// CHECK: %[[G3_VAL:.*]] = cir.load{{.*}} %[[G3_ADDR]] : !cir.ptr<!s32i>, !s32i
5252
// CHECK: %[[SUM2:.*]] = cir.binop(add, %[[SUM]], %[[G3_VAL]]) nsw : !s32i
53+
54+
using test2::f3;
55+
using test2::g3;
56+
57+
int f5() {
58+
f3();
59+
return g3;
60+
}
61+
62+
// CHECK: cir.func @_Z2f5v()
63+
// CHECK: cir.call @_ZN4test5test22f3Ev()
64+
// CHECK: %[[G3_ADDR:.*]] = cir.get_global @_ZN4test5test22g3E : !cir.ptr<!s32i>
65+
// CHECK: %[[G3_VAL:.*]] = cir.load{{.*}} %[[G3_ADDR]] : !cir.ptr<!s32i>, !s32i
66+
67+
namespace test3 {
68+
struct S {
69+
int a;
70+
} s;
71+
}
72+
73+
using test3::s;
74+
75+
int f6() {
76+
return s.a;
77+
}
78+
79+
// CHECK: cir.func @_Z2f6v()
80+
// CHECK: cir.get_global @_ZN5test31sE : !cir.ptr<!rec_test33A3AS>
81+
// CHECK: cir.get_member %{{.*}}[0] {name = "a"}
82+
83+
int shadowedFunc() {
84+
return 3;
85+
}
86+
87+
namespace shadow {
88+
using ::shadowedFunc;
89+
}
90+
91+
void f7() {
92+
shadow::shadowedFunc();
93+
}
94+
95+
// CHECK: cir.func @_Z2f7v()

0 commit comments

Comments
 (0)