Skip to content
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
8 changes: 7 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,14 @@ void CIRGenModule::emitTopLevelDecl(Decl *decl) {
break;

// No code generation needed.
case Decl::UsingShadow:
case Decl::ClassTemplate:
case Decl::Concept:
case Decl::CXXDeductionGuide:
case Decl::Empty:
case Decl::FunctionTemplate:
case Decl::StaticAssert:
case Decl::TypeAliasTemplate:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add Decl::VarTemplate, Decl::VarTemplatePartialSpecialization, Decl::Block, Decl::Binding to be complete and on par with classic codegen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable templates are covered in #151066.

I tinkered with Blocks a little bit and it seems like it's not possible to create a BlockDecl without a BlockExpr which requires codegen that's not implemented, yet. Likewise, a BindingDecl can only show up with a DecompositionDecl and while #151073 implements them on a function scope level we don't support them on in namespace scopes, yet. So these DeclKinds would be dead code which is why I didn't add them in this PR.

case Decl::UsingShadow:
break;

case Decl::CXXConstructor:
Expand Down
32 changes: 32 additions & 0 deletions clang/test/CIR/CodeGen/empty.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
// RUN: FileCheck --input-file=%t.cir %s --check-prefix=CIR

// These declarations shouldn't emit any code. Therefore the module is expected to be empty.

template<typename T>
concept some_concept = true;

template<some_concept T>
class class_template {};

; // Empty declaration

template<typename T>
void function_template();

static_assert(true, "top level static assert");

template<typename T>
using type_alias = T;

namespace N {
using ::class_template; // UsingShadow
}

template<typename T>
struct deduction_guide {};

deduction_guide() -> deduction_guide<int>;

// CIR: module {{.*}} {
// CIR-NEXT: }