Commit Graph

7 Commits

Author SHA1 Message Date
David Blaikie 7555b6a4e5 Improve some of the conversion warnings to fire on conversion to bool.
Moves the bool bail-out down a little in SemaChecking - so now
-Wnull-conversion and -Wliteral-conversion can fire when the target type is
bool.

Also improve the wording/details in the -Wliteral-conversion warning to match
the -Wconstant-conversion.

llvm-svn: 156826
2012-05-15 16:56:36 +00:00
Matt Beaumont-Gay c622163b0f Only warn in -Wliteral-conversion if the conversion loses information
llvm-svn: 141955
2011-10-14 15:36:25 +00:00
Richard Trieu 1db746afbf Move string literal to bool conversion into its own warning flag -Wstring-conversion.
llvm-svn: 140574
2011-09-26 22:38:21 +00:00
Richard Trieu 021baa373f Add a new warning to -Wliteral-conversion to catch cases where a string literal
is cast to a boolean.  An exception has been made for string literals in
logical expressions to allow the common case of use in assert statements.

bool x;
x = "hi";  // Warn here
void foo(bool x);
foo("hi");  // Warn here
assert(0 && "error");
assert("error);  // Warn here

llvm-svn: 140405
2011-09-23 20:10:00 +00:00
Matt Beaumont-Gay 042ce8e9d8 Extend -Wliteral-conversion to catch "int i = -1.234"
llvm-svn: 139326
2011-09-08 22:30:47 +00:00
Chandler Carruth 016ef400c4 Enhance the diagnostic for literal float -> int conversions to suggest
rewriting the literal when the value is integral. It is not uncommon to
see code written as:

  const int kBigNumber = 42e5;

Without any real awareness that this is no longer an ICE. The note helps
automate and ease the process of fixing code that violates the warning.

llvm-svn: 129243
2011-04-10 08:36:24 +00:00
Chandler Carruth 22c7a79a1d Implement a sub-group of -Wconversion: -Wliteral-conversion. This
specifically targets literals which are implicitly converted, a those
are more often unintended and trivial to fix. This can be especially
helpful for diagnosing what makes 'const int x = 1e6' not an ICE.

Original patch authored by Jim Meehan with contributions from other
Googlers and a few cleanups from myself.

llvm-svn: 125745
2011-02-17 11:05:49 +00:00