Author: Amr Hesham Date: 2025-12-12T18:52:36+01:00 New Revision: 366f3ac144a3d6c8d53ddf79f1391870f9a3663c
URL: https://github.com/llvm/llvm-project/commit/366f3ac144a3d6c8d53ddf79f1391870f9a3663c DIFF: https://github.com/llvm/llvm-project/commit/366f3ac144a3d6c8d53ddf79f1391870f9a3663c.diff LOG: [CIR] Add support for the ConceptSpecializationExpr (#171824) Add support for the ConceptSpecializationExpr Added: clang/test/CIR/CodeGen/concept-specialization.cpp Modified: clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp Removed: ################################################################################ diff --git a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp index d8c95389396a8..e86c62bf7793f 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp @@ -849,9 +849,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> { } mlir::Value VisitConceptSpecializationExpr(const ConceptSpecializationExpr *e) { - cgf.cgm.errorNYI(e->getSourceRange(), - "ScalarExprEmitter: concept specialization"); - return {}; + return builder.getBool(e->isSatisfied(), cgf.getLoc(e->getExprLoc())); } mlir::Value VisitRequiresExpr(const RequiresExpr *e) { cgf.cgm.errorNYI(e->getSourceRange(), "ScalarExprEmitter: requires"); diff --git a/clang/test/CIR/CodeGen/concept-specialization.cpp b/clang/test/CIR/CodeGen/concept-specialization.cpp new file mode 100644 index 0000000000000..e1fa2b831b12f --- /dev/null +++ b/clang/test/CIR/CodeGen/concept-specialization.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t.cir +// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll +// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll +// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG + +template <typename T> +concept C = sizeof(T) % 2 == 0; + +void concept_specialization() { bool a = C<int>; } + +// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["a", init] +// CIR: %[[CONST_TRUE:.*]] = cir.const #true +// CIR: cir.store {{.*}} %[[CONST_TRUE]], %[[A_ADDR]] : !cir.bool, !cir.ptr<!cir.bool> + +// LLVM: %[[A_ADDR:.*]] = alloca i8, i64 1, align 1 +// LLVM: store i8 1, ptr %[[A_ADDR]], align 1 + +// OGCG: %[[A_ADDR:.*]] = alloca i8, align 1 +// OGCG: store i8 1, ptr %[[A_ADDR]], align 1 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
