Commit Graph

12 Commits

Author SHA1 Message Date
Ted Kremenek 70f05fdfee Sema: show shift result in hexadecimal
Change the output for -Wshift-overflow and
-Wshift-sign-overflow to an unsigned hexadecimal. It makes
more sense for looking at bits than a signed decimal does.
Also, change the diagnostic's wording from "overrides"
to "sets".

This uses a new optional argument in APInt::toString()
that adds the '0x' prefix to hexademical numbers.

This fixes PR 9651.

Patch by nobled@dreamwidth.org!

llvm-svn: 133033
2011-06-15 00:54:52 +00:00
Ted Kremenek 26bbc3d494 Don't warning about shifting by too many bits in dead code.
llvm-svn: 126770
2011-03-01 19:13:22 +00:00
Ted Kremenek 63657fe995 Don't wanr about "negative shifts" in code that is unreachable. Fixes PR 5544.
llvm-svn: 126762
2011-03-01 18:09:31 +00:00
Chandler Carruth e721185799 Simplify messages as requested by Chris.
llvm-svn: 126389
2011-02-24 17:13:15 +00:00
Chandler Carruth 4c6fdca035 Implement a warning for known shift overflows on constant shift
expressions. Consider the code:

  int64_t i = 10 << 30;

This compiles fine, but most developers expect it to produce the value
for 10 gigs, not -2 gigs. This is actually undefined behavior because
the LHS is a signed integer type.

The warning is currently gated behind -Wshift-overflow.

There is a special case where only the sign bit is overridden that gets
a custom error message and is by default ignored. This case is much less
likely to cause observed buggy behavior, it's just undefined behavior
according to the spec. This warning can be enabled with
-Wshift-sign-overflow.

Original patch by Oleg Slezberg, with style tweaks and some correctness
fixes by me.

llvm-svn: 126342
2011-02-23 23:34:11 +00:00
Chandler Carruth b19289331d This really seems like a boring set of fixes to our tests to make them more
independent of the underlying system. Let me know if any of these are too
aggressive.

llvm-svn: 119345
2010-11-16 10:26:08 +00:00
Daniel Dunbar 5618e98f33 Update tests to use %clang instead of 'clang', and forcibly disable use of '
clang ' or ' clang -cc1 ' or ' clang-cc ' in test lines (by substituting them to
garbage).

llvm-svn: 91460
2009-12-15 22:01:24 +00:00
Daniel Dunbar 633d5b3ee2 Use clang to run tests which include headers from the system.
llvm-svn: 89085
2009-11-17 10:14:55 +00:00
Ryan Flynn 2f08571e4d PR4700 - remove shift by 0 warning
llvm-svn: 78488
2009-08-08 19:18:23 +00:00
Ryan Flynn f53fab87d8 PR3333: warn when shifting by invalid amount
llvm-svn: 78385
2009-08-07 16:20:20 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Chris Lattner 3c1334013d Don't do integer promotions of LHS for compound shift assignment. The LHS has to be a modifiable lvalue.
llvm-svn: 44993
2007-12-13 07:28:16 +00:00