[PATCH] D12169: Relax constexpr rules to improve __builtin_object_size's accuracy

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 4 11:47:20 PDT 2015


rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

This essentially looks fine. Let me know if you want me to take another look once you've fixed the `ignorePointerCastsAndParens` bug with derived-to-base conversions, otherwise go ahead.


================
Comment at: lib/AST/ExprConstant.cpp:499
@@ -496,1 +498,3 @@
+      /// MemberExpr with a base that can't be evaluated.
+      EM_ConstantExpressionOffsetFold,
     } EvalMode;
----------------
Maybe rename to `OffsetFold` or `DesignatorFold`?

================
Comment at: lib/AST/ExprConstant.cpp:6263-6264
@@ +6262,4 @@
+  auto *SubExpr = Cast->getSubExpr();
+  if (!SubExpr->getType()->hasPointerRepresentation() || !SubExpr->isRValue())
+    return NoParens;
+  return ignorePointerCastsAndParens(SubExpr);
----------------
I don't think this is quite right: you should only skip past casts that don't change the pointer value. In particular, this check will step past derived-to-base pointer conversions, which may require an adjustment to the pointer.


http://reviews.llvm.org/D12169





More information about the cfe-commits mailing list