Skip to content

Commit 41de9a3

Browse files
committed
[CIR] Support more declarations without any codegen
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 c03b0dd commit 41de9a3

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,8 +1267,13 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
12671267
break;
12681268

12691269
// No code generation needed.
1270-
case Decl::UsingShadow:
1270+
case Decl::ClassTemplate:
1271+
case Decl::Concept:
12711272
case Decl::Empty:
1273+
case Decl::FunctionTemplate:
1274+
case Decl::StaticAssert:
1275+
case Decl::TypeAliasTemplate:
1276+
case Decl::UsingShadow:
12721277
break;
12731278

12741279
case Decl::CXXConstructor:

clang/test/CIR/CodeGen/empty.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
// CIR: module {{.*}} {
27+
// CIR-NEXT: }

0 commit comments

Comments
 (0)