[clang] [CIR] Upstream CastOp and scalar conversions (PR #130690)
Morris Hafner via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 14 13:45:48 PDT 2025
================
@@ -121,29 +364,173 @@ mlir::Value CIRGenFunction::emitScalarExpr(const Expr *e) {
return ScalarExprEmitter(*this, builder).Visit(const_cast<Expr *>(e));
}
+[[maybe_unused]] static bool MustVisitNullValue(const Expr *e) {
+ // If a null pointer expression's type is the C++0x nullptr_t, then
+ // it's not necessarily a simple constant and it must be evaluated
+ // for its potential side effects.
+ return e->getType()->isNullPtrType();
+}
+
// Emit code for an explicit or implicit cast. Implicit
// casts have to handle a more broad range of conversions than explicit
// casts, as they handle things like function to ptr-to-function decay
// etc.
mlir::Value ScalarExprEmitter::VisitCastExpr(CastExpr *ce) {
- Expr *e = ce->getSubExpr();
+ Expr *subExpr = ce->getSubExpr();
QualType destTy = ce->getType();
CastKind kind = ce->getCastKind();
+ // These cases are generally not written to ignore the result of evaluating
+ // their sub-expressions, so we clear this now.
+ ignoreResultAssign = false;
----------------
mmha wrote:
Note that `ignoreResultAssign` is a member variable and retains its value while we visit the expression. We might get called recursively so we should keep this store.
https://github.com/llvm/llvm-project/pull/130690
More information about the cfe-commits
mailing list