From 330c9837f58b2ba06c918c21df8ff56868208589 Mon Sep 17 00:00:00 2001 From: Kirill Yansitov <36601354+YazZz1k@users.noreply.github.com> Date: Fri, 22 Mar 2024 16:50:01 +0300 Subject: [PATCH] [CIR][CIRGen] Add handling __extension__ keyword for lvalue (#519) This change is taken from the original codegen --- clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 3 ++- clang/test/CIR/CodeGen/gnu-extension.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index 15e81143062c..a5fd4c6f774d 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -1012,7 +1012,8 @@ mlir::Value CIRGenFunction::evaluateExprAsBool(const Expr *E) { LValue CIRGenFunction::buildUnaryOpLValue(const UnaryOperator *E) { // __extension__ doesn't affect lvalue-ness. - assert(E->getOpcode() != UO_Extension && "not implemented"); + if (E->getOpcode() == UO_Extension) + return buildLValue(E->getSubExpr()); switch (E->getOpcode()) { default: diff --git a/clang/test/CIR/CodeGen/gnu-extension.c b/clang/test/CIR/CodeGen/gnu-extension.c index 9c12aa2877ce..960ef277053a 100644 --- a/clang/test/CIR/CodeGen/gnu-extension.c +++ b/clang/test/CIR/CodeGen/gnu-extension.c @@ -9,3 +9,11 @@ int foo(void) { return __extension__ 0b101010; } //CHECK-NEXT: cir.store [[VAL]], [[ADDR]] : !s32i, cir.ptr //CHECK-NEXT: [[LOAD_VAL:%.*]] = cir.load [[ADDR]] : cir.ptr , !s32i //CHECK-NEXT: cir.return [[LOAD_VAL]] : !s32i + +void bar(void) { + __extension__ bar; +} + +//CHECK: cir.func @bar() +//CHECK: {{.*}} = cir.get_global @bar : cir.ptr > +//CHECK: cir.return