> On Jun 12, 2017, at 12:34 PM, Eli Friedman via Phabricator
> wrote:
>
> efriedma added inline comments.
>
>
>
> Comment at: cfe/trunk/lib/CodeGen/CGExprScalar.cpp:2666
> + bool isSigned =
> indexOperand->getType()->isSignedIntegerOrEnumerationType();
> + bool mayHaveNega
efriedma added inline comments.
Comment at: cfe/trunk/lib/CodeGen/CGExprScalar.cpp:2666
+ bool isSigned = indexOperand->getType()->isSignedIntegerOrEnumerationType();
+ bool mayHaveNegativeGEPIndex = isSigned || isSubtraction;
+
This logic doesn't look quite ri
This revision was automatically updated to reflect the committed changes.
Closed by commit rL305216: [ubsan] Detect invalid unsigned pointer index
expression (clang) (authored by vedantk).
Changed prior to commit:
https://reviews.llvm.org/D33910?vs=101479&id=102214#toc
Repository:
rL LLVM
h
dtzWill accepted this revision.
dtzWill added a comment.
LGTM!
Sorry for missing this originally, as a perhaps interesting note:
the checks were extracted from a research prototype that worked at the IR level
--where pointer itself is unsigned but the offsets (including the computed
total offse
vsk added a comment.
I've encountered some new diagnostics when running tests on a stage2
instrumented clang, and will need more time to investigate them. Sorry for the
delayed communication, I am a bit swamped this week owing to wwdc and being a
build cop.
https://reviews.llvm.org/D33910
vsk updated this revision to Diff 101479.
vsk marked 3 inline comments as done.
vsk added a comment.
Thanks for the review comments. I've changed the calls which use Builder as
suggested, and fixed up the tests.
It sounds like this patch is in good shape, so I'll commit this after two days
prov
rsmith added a comment.
Looks good, with a couple of tweaks (and corresponding test changes).
Comment at: lib/CodeGen/CGExprScalar.cpp:3910-3911
(Opcode == BO_Add) ? SAddIntrinsic : SMulIntrinsic, {LHS, RHS});
OffsetOverflows = Builder.CreateOr(
OffsetOve
regehr added a comment.
I'm afraid I don't have a better name for this.
Here's the obligatory gcc explorer link though: https://godbolt.org/g/s10h0O
https://reviews.llvm.org/D33910
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://list
vsk created this revision.
Adding an unsigned offset to a base pointer has undefined behavior if
the result of the expression would precede the base. An example from
@regehr:
int foo(char *p, unsigned offset) {
return p + offset >= p; // This may be optimized to '1'.
}
foo(p, -1); //