[clang] [CIR] Upstream CastOp and scalar conversions (PR #130690)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 12 14:47:23 PDT 2025


================
@@ -121,29 +375,174 @@ 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;
----------------
erichkeane wrote:

Is this variable used?  

https://github.com/llvm/llvm-project/pull/130690


More information about the cfe-commits mailing list