Commit Graph

1485 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 7e71884ecb Correct r124242 making sure function chunk that gets diagnosed is really about the block.
Clairvoyance by John!

llvm-svn: 124264
2011-01-26 01:26:44 +00:00
Argyrios Kyrtzidis 4e52cc7de4 Diagnose calling convention attribute incompatibilities. Fixes rdar://8876096.
llvm-svn: 124244
2011-01-25 23:16:40 +00:00
Argyrios Kyrtzidis 20ad245e3e Change error "function cannot return array type" -> "blocks cannot return array type" when blocks are involved.
Addresses rdar://8876238.

llvm-svn: 124242
2011-01-25 23:16:33 +00:00
Ted Kremenek bcf848f70a Teach -Wuninitialized-experimental to also warn
about uninitialized variables captured by blocks.

llvm-svn: 124213
2011-01-25 19:13:48 +00:00
John McCall 4bb483629f Change the wording of the bad-decl-for-attribute warning and error
to make it clear that we're talking about the declarations and not the types.

llvm-svn: 124175
2011-01-25 03:51:08 +00:00
Ted Kremenek 8f01420d9d Teach -Wuninitialized-experimental about sizeof().
llvm-svn: 124076
2011-01-23 17:53:04 +00:00
Ted Kremenek 33d4b5eb66 Provide -Wuninitialized-experimental fixits
for floats, and also check if 'nil' is declared
when suggesting it for initializing ObjC pointers.

llvm-svn: 124004
2011-01-21 22:49:49 +00:00
Ted Kremenek 2959fdd087 Add basic fixits for -Wuninitialized-experimental
to suggest initializations for pointer and
ObjC pointer types.

llvm-svn: 123995
2011-01-21 19:41:46 +00:00
Ted Kremenek 39fa056342 Enhance -Wuninitialized-experimental diagnostics
to issue the warning at an uninitialized variable's
declaration, but to issue notes at possible
uninitialized uses (which could be multiple).

llvm-svn: 123994
2011-01-21 19:41:41 +00:00
Ted Kremenek b82ddd6ada Add rudimentary path-sensitivity to UnintializedValuesV2
analysis for short-circuited operations.  For branch written like "if (x && y)",
we maintain two sets of dataflow values for the outgoing
branches.  This suppresses some common false positives
for -Wuninitialized-experimental.

This change introduces some assertion failures
when running on the LLVM codebase.  WIP.

llvm-svn: 123923
2011-01-20 17:37:17 +00:00
John McCall 33ddac05bb Change the canonical representation of array types to store qualifiers on the
outermost array types and not on the element type.  Move the CanonicalType
member from Type to ExtQualsTypeCommonBase;  the canonical type on an ExtQuals
node includes the qualifiers on the ExtQuals.  Assorted optimizations enabled
by this change.

getQualifiers(), hasQualifiers(), etc. should all now implicitly look through
array types.

llvm-svn: 123817
2011-01-19 10:06:00 +00:00
Ted Kremenek b63931eef6 Teach UninitializedValuesV2 to implicitly reason about C++
references by monitoring whether an access to
a variable is solely to compute it's lvalue or
to do an lvalue-to-rvalue conversion (i.e., a load).

llvm-svn: 123777
2011-01-18 21:18:58 +00:00
Argyrios Kyrtzidis e84389bf68 Properly do a float -> _Complex double conversion, fixes rdar://8875946.
llvm-svn: 123759
2011-01-18 18:49:33 +00:00
Ted Kremenek c8d55da05a Correctly enable test/Sema/unit-variables.c,
thus identifying a minor logical flaw in
UninitializedValuesV2.cpp.

llvm-svn: 123734
2011-01-18 05:00:42 +00:00
Ted Kremenek cab479f0ee Teach UninitializedValuesV2 about "int x = x" and
also properly handle confluence of loops.

llvm-svn: 123733
2011-01-18 04:53:25 +00:00
Francois Pichet 7d92ee3852 Remove a c++ file test I inadvertently added in Sema last week.
llvm-svn: 123608
2011-01-17 01:08:01 +00:00
Ted Kremenek b749a6d62a Add initial prototype for implementation of
-Wuninitialized based on CFG dataflow analysis.  WIP.

llvm-svn: 123512
2011-01-15 02:58:47 +00:00
Abramo Bagnara 1339223186 Added warning about invalid register specification for local variables.
llvm-svn: 123236
2011-01-11 15:16:52 +00:00
Francois Pichet bf711d90ed In Microsoft mode, force 64 bit hex integer constants to signed type if the LL or i64 suffix is used. This MSVC behavior.
For example:

void f(long long){ printf("long long"); }
void f(unsigned long long) { printf("unsigned long long"); }
int main() {
   f(0xffffffffffffffffLL);
}
Will print "long long" using MSVC.

This patch also fixes 16 compile errors related to overloading issues when parsing the MSVC 2008 C++ standard lib.

llvm-svn: 123231
2011-01-11 12:23:00 +00:00
Ted Kremenek bf4832cda8 Add semantic checking that the "thousands grouping"
prefix in a printf format string is matched
with the appropriate conversion specifier.

llvm-svn: 123055
2011-01-08 05:28:46 +00:00
Ted Kremenek a322cae011 Add printf format string parsing support for '
prefix to format conversions (POSIX extension).

llvm-svn: 123054
2011-01-08 05:28:38 +00:00
Ted Kremenek ef81e9e243 Fix crash in CFGBuilder on invalid code. We still need
to reject this code, but at least clang doesn't
crash anymore.

Crash reported in PR 8880.

llvm-svn: 123017
2011-01-07 19:37:16 +00:00
John McCall 3882ace207 Refactor the application of type attributes so that attributes from
the declaration-specifiers and on the declarator itself are moved
to the appropriate declarator chunk.  This permits a greatly
simplified model for how to apply these attributes, as well as
allowing a much more efficient query for the GC attribute.
Now all qualifier queries follow the same basic strategy of
"local qualifiers, local qualifiers on the canonical type,
then look through arrays".  This can be easily optimized by
changing the canonical qualified-array-type representation.

Do not process type attributes as decl attributes on declarations
with declarators.

When computing the type of a block, synthesize a prototype
function declarator chunk if the decl-spec type was not a
function.  This simplifies the logic for building block signatures.

Change the logic which inserts an objc_read_weak on a block
literal to only fire if the block has a __weak __block variable,
rather than if the return type of the block is __weak qualified,
which is not actually a sensible thing to ask.

llvm-svn: 122871
2011-01-05 12:14:39 +00:00
Chandler Carruth a92409c3ec Enhance the diagnostic for negative array sizes to include the
declaration name of the array when present. This ensures that
a poor-man's C++03 static_assert will include the user error message
often embedded in the name.

Update all the tests to reflect the new wording, and add a test for the
name behavior.

llvm-svn: 122802
2011-01-04 04:44:35 +00:00
Douglas Gregor bfe022caa1 When we attempt to create a built-in that involves a library type we
don't have access to (e.g., fprintf, which needs the library type
FILE), fail with a warning and forget about the builtin
entirely. Previously, we would actually provide an error, which breaks
autoconf's super-lame checks for fprintf, longjmp, etc. Fixes PR8316.

llvm-svn: 122744
2011-01-03 09:37:44 +00:00
Rafael Espindola 478abcab3d Produce a better error message for invalid register names.
llvm-svn: 122670
2011-01-01 21:47:03 +00:00
Abramo Bagnara fbd2c6a022 Added scalar casts test.
llvm-svn: 122599
2010-12-28 17:19:27 +00:00
Abramo Bagnara 9e0e7096a3 Improved complex constants evaluation.
llvm-svn: 121616
2010-12-11 16:05:48 +00:00
Rafael Espindola 0017c5fa92 Fix PR8720 by printing an error message with a substring that the gcc testsuite searches for.
llvm-svn: 121137
2010-12-07 15:23:23 +00:00
John McCall 29cb2fdbc1 When deciding whether to complain about the type of a boolean condition, use
the type of the expression *after* array/function decay.

llvm-svn: 120895
2010-12-04 06:09:13 +00:00
John McCall 34376a68c4 Although we currently have explicit lvalue-to-rvalue conversions, they're
not actually frequently used, because ImpCastExprToType only creates a node
if the types differ.  So explicitly create an ICE in the lvalue-to-rvalue
conversion code in DefaultFunctionArrayLvalueConversion() as well as several
other new places, and consistently deal with the consequences throughout the
compiler.

In addition, introduce a new cast kind for loading an ObjCProperty l-value,
and make sure we emit those nodes whenever an ObjCProperty l-value appears
that's not on the LHS of an assignment operator.

This breaks a couple of rewriter tests, which I've x-failed until future
development occurs on the rewriter.

Ted Kremenek kindly contributed the analyzer workarounds in this patch.

llvm-svn: 120890
2010-12-04 03:47:34 +00:00
Argyrios Kyrtzidis 86a26b8e35 Mark functions referenced by 'cleanup' attribute as used. Fixes rdar://8728293
llvm-svn: 120872
2010-12-04 01:12:11 +00:00
Peter Collingbourne 19b961d5f9 Merge transparent union types using member's unqualified type
llvm-svn: 120736
2010-12-02 21:00:06 +00:00
Ted Kremenek 9e618ed1c9 Fix range in printf warnings for invalid conversion specifiers.
llvm-svn: 120735
2010-12-02 20:57:51 +00:00
Peter Collingbourne 102ad54099 Merge transparent union types using member's canonical param type
llvm-svn: 120729
2010-12-02 20:02:29 +00:00
Bob Wilson 2e71fb55c1 Attempt to fix linux buildbots by adding -ffreestanding for arm_neon tests.
The arm_neon.h header includes stdint.h and it picks up the system header
without -ffreestanding.

llvm-svn: 120716
2010-12-02 17:31:16 +00:00
Bob Wilson 27d87807f6 Add a test for calling a Neon intrinsic macro with the wrong vector type.
This does not work so well with the -fno-lax-vector-conversions option for
testing the arm_neon.h header but that is a really useful test, so I split
this out to a separate Sema test to check for the warning.

llvm-svn: 120694
2010-12-02 07:13:31 +00:00
Fariborz Jahanian e1802eefac Incomplete enum types not to be treated as integer type
when checking for integer signed/unsigned-ness. PR8694,
// rdar://8707031

llvm-svn: 120345
2010-11-29 23:18:09 +00:00
Francois Pichet 0c71f6c5d3 Microsoft C anonymous struct implementation.
Documentation: http://msdn.microsoft.com/en-us/library/z2cx9y4f.aspx

llvm-svn: 120000
2010-11-23 06:07:27 +00:00
NAKAMURA Takumi 3c3b3a7d8b test/Sema/x86-builtin-palignr.c: Now we can remove XFAIL:win32, according to r119958.
llvm-svn: 119961
2010-11-22 09:29:49 +00:00
Anders Carlsson a369f8dc3a The 'X' printf type has a valid alternative form. Fixes PR8641.
llvm-svn: 119946
2010-11-21 18:34:21 +00:00
Argyrios Kyrtzidis 90ee2a4ecf Don't warn for empty 'if' body if there is a macro that expands to nothing, e.g:
if (condition)
    CALL(0); // empty macro but don't warn for empty body.

Fixes rdar://8436021.

llvm-svn: 119838
2010-11-19 20:54:25 +00:00
Anton Yartsev 3f8f2886c1 comparison of AltiVec vectors now gives bool result (fix for 7533)
llvm-svn: 119678
2010-11-18 03:19:30 +00:00
Argyrios Kyrtzidis 56e879d1da Don't emit warn_logical_and_in_logical_or for cases like "a && b || 0".
llvm-svn: 119540
2010-11-17 19:18:19 +00:00
Argyrios Kyrtzidis 14a96625b8 Don't warn for parentheses for the '&&' inside '||' for cases like:
assert(a || b && "bad");

since this is safe. This way we avoid a big source of such warnings which in this case are practically useless.

Note that we don't handle *all* cases where precedence wouldn't matter because of constants since
this is a bit costly to check, and IMO clarifying precedence with parentheses is good for
readability in general.

llvm-svn: 119533
2010-11-17 18:26:36 +00:00
Argyrios Kyrtzidis f89a56c74b Warn about arg1 && arg2 || arg3, as GCC 4.3+ does. Fixes rdar://8659922
llvm-svn: 119381
2010-11-16 21:00:12 +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
Bob Wilson 1d54ee75da Add tests for new Neon vector type attributes.
llvm-svn: 119303
2010-11-16 00:32:28 +00:00
John McCall deebbcf20d Undo a refactor-o and base the bitfield-truncation warning on the
uncoerced value.  Also, whitelist bool bitfields, which aren't
really a truncation.

llvm-svn: 118778
2010-11-11 05:33:51 +00:00
John McCall 1f425648ca Extend the bitfield-truncation warning to initializations.
rdar://problem/8652606

llvm-svn: 118773
2010-11-11 03:21:53 +00:00