[clang] [CIR] Upstream support for emitting ignored statements (PR #130869)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 12 07:56:57 PDT 2025
================
@@ -165,6 +165,33 @@ LValue CIRGenFunction::emitDeclRefLValue(const DeclRefExpr *e) {
return LValue();
}
+/// Emit code to compute the specified expression which
+/// can have any type. The result is returned as an RValue struct.
+RValue CIRGenFunction::emitAnyExpr(const Expr *e, bool ignoreResult) {
+ switch (CIRGenFunction::getEvaluationKind(e->getType())) {
+ case cir::TEK_Scalar:
+ return RValue::get(emitScalarExpr(e));
+ case cir::TEK_Complex:
+ cgm.errorNYI(e->getSourceRange(), "emitAnyExpr: complex type");
+ return RValue::get(nullptr);
+ case cir::TEK_Aggregate:
+ cgm.errorNYI(e->getSourceRange(), "emitAnyExpr: aggregate type");
+ return RValue::get(nullptr);
+ }
+ llvm_unreachable("bad evaluation kind");
+}
+
+/// Emit code to compute the specified expression, ignoring the result.
+void CIRGenFunction::emitIgnoredExpr(const Expr *e) {
+ if (e->isPRValue()) {
+ assert(!cir::MissingFeatures::aggValueSlot());
+ return (void)emitAnyExpr(e, true);
----------------
erichkeane wrote:
hah, this line is perhaps overly cute.
https://github.com/llvm/llvm-project/pull/130869
More information about the cfe-commits
mailing list