Skip to content

Commit fefc579

Browse files
AmrDevelopergithub-actions[bot]
authored andcommitted
Automerge: [CIR] Add support for ExpressionTraitExpr (#171634)
Add support for the ExpressionTraitExpr
2 parents 19c9b4b + ec4aba3 commit fefc579

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,9 +859,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
859859
return {};
860860
}
861861
mlir::Value VisitExpressionTraitExpr(const ExpressionTraitExpr *e) {
862-
cgf.cgm.errorNYI(e->getSourceRange(),
863-
"ScalarExprEmitter: expression trait");
864-
return {};
862+
return builder.getBool(e->getValue(), cgf.getLoc(e->getExprLoc()));
865863
}
866864
mlir::Value VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *e) {
867865
cgf.cgm.errorNYI(e->getSourceRange(),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
void expression_trait_expr() {
9+
bool a = __is_lvalue_expr(0);
10+
}
11+
12+
// CIR: %[[A_ADDR:.*]] = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["a", init]
13+
// CIR: %[[CONST_FALSE:.*]] = cir.const #false
14+
// CIR: cir.store {{.*}} %[[CONST_FALSE]], %[[A_ADDR]] : !cir.bool, !cir.ptr<!cir.bool>
15+
16+
// LLVM: %[[A_ADDR:.*]] = alloca i8, i64 1, align 1
17+
// LLVM: store i8 0, ptr %[[A_ADDR]], align 1
18+
19+
// OGCG: %[[A_ADDR:.*]] = alloca i8, align 1
20+
// OGCG: store i8 0, ptr %[[A_ADDR]], align 1

0 commit comments

Comments
 (0)