Skip to content

Commit 77f8a91

Browse files
authored
[CIR] Support more declarations without any codegen (#151076)
This patch adds or completes support for a couple of top level declaration types that don't emit any code: Most notably these include Concepts, static_assert and type aliases.
1 parent c923d96 commit 77f8a91

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,8 +1331,14 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
13311331
break;
13321332

13331333
// No code generation needed.
1334-
case Decl::UsingShadow:
1334+
case Decl::ClassTemplate:
1335+
case Decl::Concept:
1336+
case Decl::CXXDeductionGuide:
13351337
case Decl::Empty:
1338+
case Decl::FunctionTemplate:
1339+
case Decl::StaticAssert:
1340+
case Decl::TypeAliasTemplate:
1341+
case Decl::UsingShadow:
13361342
break;
13371343

13381344
case Decl::CXXConstructor:

clang/test/CIR/CodeGen/empty.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR
3+
4+
// These declarations shouldn't emit any code. Therefore the module is expected to be empty.
5+
6+
template<typename T>
7+
concept some_concept = true;
8+
9+
template<some_concept T>
10+
class class_template {};
11+
12+
; // Empty declaration
13+
14+
template<typename T>
15+
void function_template();
16+
17+
static_assert(true, "top level static assert");
18+
19+
template<typename T>
20+
using type_alias = T;
21+
22+
namespace N {
23+
using ::class_template; // UsingShadow
24+
}
25+
26+
template<typename T>
27+
struct deduction_guide {};
28+
29+
deduction_guide() -> deduction_guide<int>;
30+
31+
// CIR: module {{.*}} {
32+
// CIR-NEXT: }

0 commit comments

Comments
 (0)