Skip to content

Commit 366f3ac

Browse files
authored
[CIR] Add support for the ConceptSpecializationExpr (#171824)
Add support for the ConceptSpecializationExpr
1 parent 26ff166 commit 366f3ac

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,9 +849,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
849849
}
850850
mlir::Value
851851
VisitConceptSpecializationExpr(const ConceptSpecializationExpr *e) {
852-
cgf.cgm.errorNYI(e->getSourceRange(),
853-
"ScalarExprEmitter: concept specialization");
854-
return {};
852+
return builder.getBool(e->isSatisfied(), cgf.getLoc(e->getExprLoc()));
855853
}
856854
mlir::Value VisitRequiresExpr(const RequiresExpr *e) {
857855
cgf.cgm.errorNYI(e->getSourceRange(), "ScalarExprEmitter: requires");
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
5+
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7+
8+
template <typename T>
9+
concept C = sizeof(T) % 2 == 0;
10+
11+
void concept_specialization() { bool a = C<int>; }
12+
13+
// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["a", init]
14+
// CIR: %[[CONST_TRUE:.*]] = cir.const #true
15+
// CIR: cir.store {{.*}} %[[CONST_TRUE]], %[[A_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
16+
17+
// LLVM: %[[A_ADDR:.*]] = alloca i8, i64 1, align 1
18+
// LLVM: store i8 1, ptr %[[A_ADDR]], align 1
19+
20+
// OGCG: %[[A_ADDR:.*]] = alloca i8, align 1
21+
// OGCG: store i8 1, ptr %[[A_ADDR]], align 1

0 commit comments

Comments
 (0)