Re: [PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-12 Thread Vedant Kumar via cfe-commits
> 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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-12 Thread Eli Friedman via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-12 Thread Phabricator via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-12 Thread Will Dietz via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-08 Thread Vedant Kumar via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread Vedant Kumar via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread John Regehr via Phabricator via cfe-commits
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

[PATCH] D33910: [ubsan] Detect invalid unsigned pointer index expression (clang)

2017-06-05 Thread Vedant Kumar via Phabricator via cfe-commits
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); //