[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)
Filipe Cabecinhas via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 9 06:25:36 PST 2017
filcab added a comment.
Minor nits, now.
LGTM, but having someone more familiar with clang chime in would be great.
================
Comment at: lib/CodeGen/CGExprScalar.cpp:1700
case LangOptions::SOB_Trapping:
+ if (getUnwidenedIntegerType(CGF.getContext(), E->getSubExpr()).hasValue())
+ return Builder.CreateNSWAdd(InVal, Amount, Name);
----------------
Maybe a helper `IsWidenedIntegerOp(...)` (or `IsOpWiderThanBaseType`or something) would make this (and others, like the first return of `getUnwidenedIntegerType`) easier to read?
================
Comment at: test/CodeGen/ubsan-promoted-arith.cpp:90
+
+// Note: -INT_MIN / -1 can overflow.
+//
----------------
Extra `-`. `INT_MIN/-1` is what you want. You already have a test above for `-INT_MIN` (which would overflow before the division.
https://reviews.llvm.org/D29369
More information about the cfe-commits
mailing list