[PATCH] D33563: Track whether a unary operation can overflow

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 6 13:48:46 PST 2018

aaron.ballman added a comment.

Thanks for the review!

Comment at: include/clang/AST/Expr.h:1728
+  UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK,
+                ExprObjectKind OK, SourceLocation l, bool CanOverflow = false)
+      : Expr(UnaryOperatorClass, type, VK, OK,
efriedma wrote:
> Is the default argument necessary here?  Better to avoid when possible.
It's not required, but there are quite a few places where we gin up a UnaryOperator for things like address of or dereference where there is no overflow possible. However, I agree that less default arguments are better, so I've made it a required formal argument.

Comment at: test/Misc/ast-dump-stmt.c:66
+  // CHECK:        ImplicitCastExpr
+  // CHECK:          DeclRefExpr{{.*}}'T2' 'int'
efriedma wrote:
> What does it mean for bitwise complement to "overflow"?
When the sign bit flips on a signed value, e.g., `~0`.


More information about the cfe-commits mailing list