Commit Graph

25257 Commits

Author SHA1 Message Date
Anna Zaks 62cce9e47d [analyzer] Do not highlight the range of the statement in case of leak.
We report a leak at a point a leaked variable is no longer accessible.
The statement that happens to be at that point is not relevant to the
leak diagnostic and, thus, should not be highlighted.

radar://11178519

llvm-svn: 156530
2012-05-10 01:37:40 +00:00
Fariborz Jahanian 7a055366f2 objective-c. Fixes a 'fixit' where location of
'*' on objective-c class name was misplaced.
// rdar://11311333

llvm-svn: 156517
2012-05-09 21:49:29 +00:00
Richard Trieu 43a2fc7b9e Pull some cases of initialization with self-reference warnings out of
-Wconditional-uninitialized into -Wuninitialized.

llvm-svn: 156512
2012-05-09 21:08:22 +00:00
Richard Smith 2f07ad5a70 Push the knowledge that we are parsing a type-id/type-name further into the
parser, and use it to emit better diagnostics in cases where an identifer
can't be looked up as a type name.

llvm-svn: 156508
2012-05-09 20:55:26 +00:00
Richard Smith 3092a3b43c Stop AltiVec parsing from going down the 'implicit int' codepath as part of its
normal parse for token sequences like 'vector pixel foo'. This incidentally also
fixes a couple of wrong-parse issues.

llvm-svn: 156503
2012-05-09 18:56:43 +00:00
Chad Rosier 7b1fee1fe5 Roll logic into a single if statement, per David's suggestion.
llvm-svn: 156502
2012-05-09 18:55:57 +00:00
Chad Rosier bf8628e62f Use the triple directly, rather then getTriple().
llvm-svn: 156501
2012-05-09 18:51:13 +00:00
Chad Rosier 266c620623 Now the proper fix for r156497. Sorry for the churn.
llvm-svn: 156498
2012-05-09 18:46:30 +00:00
Chad Rosier 6037c6bae0 Move the iOSVersionMin string to a header so as to avoid a dangling pointer.
llvm-svn: 156497
2012-05-09 18:37:26 +00:00
David Blaikie c9bd941f1f Fix -Wdelete-non-virtual-dtor in Tooling code.
Also, add an anchor as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch

llvm-svn: 156495
2012-05-09 18:31:50 +00:00
Roman Divacky d966e723f7 Implement PPC64TargetCodeGenInfo.
llvm-svn: 156491
2012-05-09 18:22:46 +00:00
Chad Rosier f761fe9d23 [driver] Use the iOS target triple to infer the deployment target.
rdar://11409204

llvm-svn: 156489
2012-05-09 18:09:58 +00:00
Bob Wilson e78227b1ff Ignore a "generic" return value from getHostCPUName. <rdar://problem/11314502>
llvm-svn: 156487
2012-05-09 17:53:10 +00:00
Anna Zaks d60f4c8fef [analyzer] Simplify r156446, as per Ted's review.
llvm-svn: 156482
2012-05-09 17:23:15 +00:00
Anna Zaks 325520a7b8 [analyzer] Allow pointers to escape through selector callbacks.
llvm-svn: 156481
2012-05-09 17:23:11 +00:00
Simon Atanasyan 32df72db66 Declare abstract class ArgumentsAdjuster. This abstract interface describes
a command line argument adjuster, which is responsible for command line
arguments modification before the arguments are used to run a frontend action.

Define class ClangSyntaxOnlyAdjuster implements ArgumentsAdjuster interface.
This class converts input command line arguments to the "syntax check only"
variant.

Reviewed by Manuel Klimek.

llvm-svn: 156478
2012-05-09 16:18:30 +00:00
Argyrios Kyrtzidis 08f96a9b5e [AST/libclang] Speed up clang_getOverriddenCursors() considerably by reserving a bit
in ObjCMethodDecl to indicate whether the method does not override any other method,
which is the majority of cases.

That way we can avoid unnecessary work doing lookups, especially when PCH is involved.

rdar://11360082

llvm-svn: 156476
2012-05-09 16:12:57 +00:00
Nuno Lopes ddcce0bb90 update calls to objectsize intrinsic to match LLVM r156473
add a test for -fbounds-checking code generation

llvm-svn: 156474
2012-05-09 15:53:34 +00:00
Richard Smith 45855df4c6 Recover properly if a class member declaration starts with a scope specifier
or template-id which can't be parsed.

llvm-svn: 156468
2012-05-09 08:23:23 +00:00
Ted Kremenek 7ebb493375 Teach IsTailPaddedMemberArray() (used by -Warray-bounds) that a FieldDecl may have a Typedef type, and not always a ConstantArrayType.
Fixes <rdar://problem/11387038>.

llvm-svn: 156464
2012-05-09 05:35:08 +00:00
Richard Smith 6f8d2c6c9c A little tweak to the SFINAE condition reporting. Don't say:
candidate template ignored: substitution failed [with T = int]: no type named 'type' in 'std::enable_if<false, void>'

Instead, just say:

  candidate template ignored: disabled by 'enable_if' [with T = int]

... and point at the enable_if condition which (we assume) failed.

This is applied to all cases where the user writes 'typename enable_if<...>::type' (optionally prefixed with a nested name specifier), and 'enable_if<...>' names a complete class type which does not have a member named 'type', and this results in a candidate function being ignored in a SFINAE context. Thus it catches 'std::enable_if', 'std::__1::enable_if', 'boost::enable_if' and 'llvm::enable_if'.

llvm-svn: 156463
2012-05-09 05:17:00 +00:00
Richard Trieu 64c51abf7f Update the SelfReferenceChecker. Refactored some of the visitor methods.
Added support for conditional operators and tightened the exclusion of the
unary operator from all operators to only the address of operator.

llvm-svn: 156450
2012-05-09 00:21:34 +00:00
Fariborz Jahanian 89919ccd17 Modern objective-c translation. Translating default
synthesis of property getter/setters. // rdar://11374235

llvm-svn: 156447
2012-05-08 23:54:35 +00:00
Anna Zaks d0f89283cf [analyzer] We currently do not fully support CompoundLiterals in
RegionStore, so be explicit about it and generate UnknownVal().

This is a hack to ensure we never produce undefined values for a value
coming from a compound value. (The undefined values can lead to
false positives.) 

radar://10127782

llvm-svn: 156446
2012-05-08 23:40:38 +00:00
Nuno Lopes 3d6311d5f7 add -fbounds-checking option.
When enabled, clang generates bounds checks for array and pointers dereferences. Work to follow in LLVM's backend.

OK'ed by Chad; thanks for the review.

llvm-svn: 156431
2012-05-08 22:10:46 +00:00
Ted Kremenek f534e91882 Having RegionStore lower field bindings to raw offsets, just like ElementRegions. This is a bit
disruptive, but it allows RegionStore to better "see" through casts that reinterpret arrays of values
as structs.  Fixes <rdar://problem/11405978>.

llvm-svn: 156428
2012-05-08 21:49:54 +00:00
Ted Kremenek b4235b48ca When creating lazy bindings in RegionStore, propagate existing lazy bindings instead of creating new ones.
This is a functionality optimization.

llvm-svn: 156427
2012-05-08 21:49:51 +00:00
Ted Kremenek 228571b69b Include address of Store in graphviz output of ExplodedGraph.
llvm-svn: 156426
2012-05-08 21:49:47 +00:00
John McCall 0bd3e404af Bind cleanups after doing l2r conversion on the operand of a
@throw expression;  l2r conversion can introduce new cleanups
in certain cases, like when the expression is an ObjC property
reference of retainable type in ARC.

llvm-svn: 156425
2012-05-08 21:41:25 +00:00
Anna Zaks 66843480a6 [analyzer] SelfInit: Stop tracking self if it's assigned a value we
don't reason about.

Self is just like a local variable in init methods, so it can be
assigned anything like result of static functions, other methods ... So
to suppress false positives that result in such cases, stop tracking the
checker-specific state after self is being assigned to (unless the
value is't being assigned to is either self or conforms to our rules).

This change does not invalidate any existing regression tests.

llvm-svn: 156420
2012-05-08 21:19:21 +00:00
Fariborz Jahanian 9c0c0501e8 modern objc translation. objc_getClass() and objc_getMetaClass()
prototypes should both return  `struct objc_class *`.
// rdar://11375495

llvm-svn: 156418
2012-05-08 20:55:55 +00:00
Eric Christopher c0e7a3d78c The address of a vla is actually complex and requires a dereference.
Part of rdar://11352000

llvm-svn: 156407
2012-05-08 18:56:47 +00:00
Eric Christopher 40d057fd7d Whitespace.
llvm-svn: 156406
2012-05-08 18:56:42 +00:00
Fariborz Jahanian d6886e7fad Fixes a typo. note_xxx not not_xxx.
llvm-svn: 156391
2012-05-08 18:03:39 +00:00
Hans Wennborg 967b9cec23 Make -Wformat accept printf("%hhx", c); with -funsigned-char
For "%hhx", printf expects an unsigned char. This makes Clang
accept a 'char' argument for that also when using -funsigned-char.

This fixes PR12761.

llvm-svn: 156388
2012-05-08 17:21:31 +00:00
Ted Kremenek e87b55214b Teach the analyzer about CXXScaleValueInitExpr.
llvm-svn: 156369
2012-05-08 05:13:40 +00:00
Jordy Rose 740b0c297c Clean up SemaDeclAttr for high-warnings build.
Includes a real potential initialization problem.

llvm-svn: 156363
2012-05-08 03:27:22 +00:00
Jordy Rose 675d541ab6 [analyzer] BasicConstraintManager: drop NE-constraints once we have a value.
This could conceivably cut down on state proliferation, although we don't
use BasicConstraintManager by default anymore. No functionality change.

llvm-svn: 156362
2012-05-08 03:27:20 +00:00
Jordy Rose 728be7f6ac [analyzer] Rework both constraint managers to handle mixed-type comparisons.
This involves keeping track of three separate types: the symbol type, the
adjustment type, and the comparison type. For example, in "$x + 5 > 0ULL",
if the type of $x is 'signed char', the adjustment type is 'int' and the
comparison type is 'unsigned long long'. Most of the time these three types
will be the same, but we should still do the right thing when the
comparison value is out of range, and wraparound should be calculated in
the adjustment type.

This also re-disables an out-of-bounds test; we were extracting the symbol
from non-additive SymIntExprs, but then throwing away the integer.

Sorry for the large patch; both the basic and range constraint managers needed
to be updated together, since they share code in SimpleConstraintManager.

llvm-svn: 156361
2012-05-08 03:27:16 +00:00
Jordy Rose 7e3c3ea341 [analyzer] Add an abstraction for the bit width and signedness of an APSInt. No functionality change.
There are more parts of the analyzer that could use the convenience of APSIntType, particularly the constraint engine, but that needs a fair amount of rewriting to handle mixed-type constraints anyway.

llvm-svn: 156360
2012-05-08 03:26:58 +00:00
Rafael Espindola 0232c19a31 Add missing 'y'.
llvm-svn: 156348
2012-05-08 00:28:39 +00:00
Ted Kremenek ececf9f0ae Teach the static analyzer that NSLog() and friends do not hold on to object references (thus extending their lifetime).
llvm-svn: 156346
2012-05-08 00:12:09 +00:00
Rafael Espindola 3c9d9479b0 Process attributes in the order they appear in the source code. This make clang
match gcc behavior for two conflicting visibilities in the same decl. It also
makes handling of dllimport/dllexport more natural.

As a bonus we now warn on the dllimport in

void __attribute__((dllimport)) foo13();
void __attribute__((dllexport)) foo13();

as does gcc.

llvm-svn: 156343
2012-05-07 23:58:18 +00:00
Anna Zaks 590c7bc12e [analyzer]Turn on MallocSizeOfChecker by default; shorten the diagnostic
llvm-svn: 156341
2012-05-07 23:30:29 +00:00
Chandler Carruth 4496c44e5f Remove the 'intrin.h' builtin header file and its tests for now.
After discussion with several people, including Doug Gregor, we've
decided to change our approach here. If you have questions about this
header file, the commit removing it, etc., please reach out to me
off-list.

llvm-svn: 156322
2012-05-07 20:46:58 +00:00
Anna Zaks 386e832c07 [analyzer] Fix a crash in triggered by OSAtomicChecker.
SValBuilder should return an UnknownVal() when comparison of int and ptr
fails. Previous to this commit, it went on assuming that we are dealing
with pointer arithmetic.

PR12509, radar://11390991

llvm-svn: 156320
2012-05-07 19:40:49 +00:00
Nuno Lopes f463abc0e7 remove code to add bound checks for simple array accesses, since those are already covered by the check with the objectsize builtin
remove the comparison of objectsize with -1. since it's an unsigned comparison, it will always succeed if objectsize returns -1, which is enough to have the check removed

llvm-svn: 156311
2012-05-07 17:57:00 +00:00
Anna Zaks 41e7ab8f81 [analyzer]Fixup r156215: use StopTracking summary instead of ScratchArgs
As per Jordy's and Ted's comment, use the default StopTracking summary
instead of adding all arguments to ScratchArs.

llvm-svn: 156310
2012-05-07 17:47:09 +00:00
Douglas Gregor 8a59a957fb Revert r156097, which appears to be causing some breakage.
llvm-svn: 156304
2012-05-07 14:17:47 +00:00
Manuel Klimek f33dcb0449 Fix includes for unices that don't have chdir declared transitively.
llvm-svn: 156302
2012-05-07 10:02:55 +00:00