Граф коммитов

1487 Коммитов

Автор SHA1 Сообщение Дата
Ted Kremenek 7453a72cd0 PlistDiagnostics: force the ranges for control-flow edges to be single locations, forcing
adjacent edges to have compatible ranges.  This simplifies the layout logic for some clients.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158028 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-05 22:00:52 +00:00
Anna Zaks d5edd849b6 [analyzer] Fixup for r157950. Unbreak the bots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157954 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 21:59:02 +00:00
Anna Zaks 0344e5423d [analyzer] Fix a diagnostics bug which lead to a crash on the buildbot.
This bug was triggered by r157851. It only happens in the case where we
don't perform optimal diagnostic pruning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157950 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-04 21:03:31 +00:00
Anna Zaks 183ff2aaac [analyzer] Fix a spurious undef value warning.
When we timeout or exceed a max number of blocks within an inlined
function, we retry with no inlining starting from a node right before
the CallEnter node. We assume the state of that node is the state of the
program before we start evaluating the call. However, the node pruning
removes this node as unimportant. 

Teach the node pruning to keep the predecessors of the call enter nodes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157860 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 23:48:44 +00:00
Anna Zaks 144e52be48 [analyzer] Fix lack of coverage after empty inlined function.
We should not stop exploring the path after we return from an empty
function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157859 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 23:48:40 +00:00
Ted Kremenek 7fa9b4f258 static analyzer: add inlining support for directly called blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157833 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-01 20:04:04 +00:00
Fariborz Jahanian 350e956532 -Wdeprecated warning to include reference (as a note)
to the declaration in this patch. // rdar://10893232


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157537 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-27 16:59:48 +00:00
Richard Smith bdb97ff687 In response to some discussions on IRC, tweak the wording of the new
-Wsometimes-uninitialized diagnostics to make it clearer that the cause
of the issue may be a condition which must always evaluate to true or
false, rather than an uninitialized variable.

To emphasize this, add a new note with a fixit which removes the
impossible condition or replaces it with a constant.

Also, downgrade the diagnostic from -Wsometimes-uninitialized to
-Wconditional-uninitialized when it applies to a range-based for loop,
since the condition is not written explicitly in the code in that case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157511 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-26 06:20:46 +00:00
Anna Zaks e41458c379 [analyzer] Don't crash on LValBitCast
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157478 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-25 16:02:16 +00:00
Richard Smith 2815e1a075 Split a chunk of -Wconditional-uninitialized warnings out into a separate flag,
-Wsometimes-uninitialized. This detects cases where an explicitly-written branch
inevitably leads to an uninitialized variable use (so either the branch is dead
code or there is an uninitialized use bug).

This chunk of warnings tentatively lives within -Wuninitialized, in order to
give it more visibility to existing Clang users.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157458 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-25 02:17:09 +00:00
Anna Zaks 17eb65f1bf [analyzer] Treat cast of array to reference in the same way as array to
pointer.

Fixes one of the crashes reported in PR12874.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157401 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 17:31:57 +00:00
Anna Zaks 98553e8941 [analyzer] Fix typo. Thanks Jordy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157400 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-24 17:31:54 +00:00
Simon Atanasyan d95e95ec53 Replace inline asm constraint "=a" by the more general constraint "=r".
That extend a range of platforms support this test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157247 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-22 11:03:10 +00:00
Anna Zaks 13dd47a0c0 [analyzer] Bind UnknownVal to InitListExpr for unsupported types
(ex: float).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157211 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-21 22:07:00 +00:00
Benjamin Kramer b7824d9919 Analyzer: Fix PR12905, a crash when encountering a call to a function named "C".
While there clean up indentation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157204 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-21 19:40:38 +00:00
Anna Zaks 671e3bc1a1 [analyzer] c++11: do not crash on namespace alias
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157089 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-19 00:22:11 +00:00
Anna Zaks 719b429e3e [analyzer] Fix a c++11 crash: xvalues can be locations (VisitMemberExpr)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157082 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-18 22:47:43 +00:00
Anna Zaks 1434518f17 [analyzer]Malloc: refactor and report use after free by memory
allocating functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157037 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-18 01:16:10 +00:00
Jordy Rose 6d2b92e15f Add triples for test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156949 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 21:13:36 +00:00
Jordy Rose f158b7181c [analyzer] Fix test for PR12206, which was failing on i386.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156941 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 20:29:44 +00:00
Anna Zaks 533718fb27 [analyzer] Revert a regression committed in r156920.
This breaks the build with -triple i386-apple-darwin9.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156932 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 18:46:25 +00:00
Jordy Rose e337cba7c5 [analyzer] Fix RUN lines for old XFAIL tests, one of which actually works.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156921 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 16:01:14 +00:00
Jordy Rose 43d9f0d4e9 [analyzer] Convert many existing tests to use clang_analyzer_eval.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156920 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 16:01:10 +00:00
Jordy Rose 93a9d82837 [analyzer] Introduce clang_analyzer_eval for regression test constraint checks.
The new debug.ExprInspection checker looks for calls to clang_analyzer_eval,
and emits a warning of TRUE, FALSE, or UNKNOWN (or UNDEFINED) based on the
constrained value of its (boolean) argument. It does not modify the analysis
state though the conditions tested can result in branches (e.g. through the
use of short-circuit operators).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156919 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-16 16:01:07 +00:00
Anna Zaks f1db0c9d8d [analyzer] Add a test for dead stores, which uses OpaqueValExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156875 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 23:12:53 +00:00
Anna Zaks 5ec351c950 [analyzer] Fix a regression in ObjCUnusedIVars checker.
We can no longer rely on children iterator to visit all the AST
tree children of an expression (OpaqueValueExpr has no children).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156870 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 22:31:56 +00:00
David Blaikie be0ee875d8 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156826 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-15 16:56:36 +00:00
Anna Zaks 45246a7fc0 [analyzer] Fix a crash in templated code which uses blocks.
We should investigate why signature info is not set in this case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156784 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-14 22:38:24 +00:00
Jordy Rose 6e4244ee86 [analyzer] strncpy: Special-case a length of 0 to avoid an incorrect warning.
We check the address of the last element accessed, but with 0 calculating that
address results in element -1. This patch bails out early (and avoids a bunch
of other work at that).

Fixes PR12807.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156769 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-14 17:58:35 +00:00
Jordy Rose f1139400e8 [analyzer] Test case: p->x is the same as p[0].x. (PR7297)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156720 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-12 17:32:59 +00:00
Jordy Rose 70fdbc366d [analyzer] RetainCountChecker: track ObjC boxed expression objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156699 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-12 05:10:43 +00:00
Anna Zaks 58715da82b [analyzer] Test variable modified types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156664 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-11 23:34:14 +00:00
Anna Zaks 297ca4593c [analyzer] Test objC boxing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156660 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-11 23:15:16 +00:00
Anna Zaks 72b74aab51 [analyzer] Add buffer overflow test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156659 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-11 23:15:11 +00:00
Anna Zaks b3b1ae8575 [analyzer] Exit early if constraint solver is given a non-integer symbol
to reason about.

As part of taint propagation, we now allow creation of non-integer
symbolic expressions like a cast from int to float.

Addresses PR12511 (radar://11215362).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156578 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-10 21:49:52 +00:00
Anna Zaks 88feba0514 [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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156530 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-10 01:37:40 +00:00
Anna Zaks caa62af79d [analyzer] Allow pointers to escape through selector callbacks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156481 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-09 17:23:11 +00:00
Anna Zaks a8f2362307 [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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156446 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 23:40:38 +00:00
Ted Kremenek 4213e389d6 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>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156428 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:49:54 +00:00
Anna Zaks 6a2a1865f8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156420 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 21:19:21 +00:00
Ted Kremenek c319c585c0 Teach the analyzer about CXXScaleValueInitExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156369 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 05:13:40 +00:00
Jordy Rose 1d8db493f8 [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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156361 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 03:27:16 +00:00
Ted Kremenek c91fdf662d Teach the static analyzer that NSLog() and friends do not hold on to object references (thus extending their lifetime).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156346 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-08 00:12:09 +00:00
Anna Zaks ca11510d39 [analyzer]Turn on MallocSizeOfChecker by default; shorten the diagnostic
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156341 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 23:30:29 +00:00
Anna Zaks 6400f02ab2 [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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156320 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-07 19:40:49 +00:00
Jordy Rose c838fd2ab8 [analyzer] Reduce parallel code paths in SimpleSValBuilder::evalBinOpNN, and handle mixed-type operations more generally.
The logical change is that the integers in SymIntExprs may not have the same type as the symbols they are paired with. This was already the case with taint-propagation expressions created by SValBuilder::makeSymExprValNN, but I think those integers may never have been used. SimpleSValBuilder should be able to handle mixed-integer-type SymIntExprs fine now, though, and the constraint managers were already being defensive (though not entirely correct). All existing tests pass.

The logic in evalBinOpNN has been simplified so that conversion is done as late as possible. As a result, most of the switch cases have been reduced to do the minimal amount of work, delegating to another case when they can by substituting ConcreteInts and (as before) reversing the left and right arguments when useful.

Comparisons require special handling in two places (building SymIntExprs and evaluating constant-constant operations) because we don't /know/ the best type for comparing the two values. I've approximated the rules in Sema [C99 6.3.1.8]  but it'd be nice to refactor Sema's actual algorithm into ASTContext.

This is also groundwork for handling mixed-type constraints better than we do now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156270 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-06 23:40:02 +00:00
Anna Zaks 58822c403c [analyzer] RetainCountChecker: Allow objects to escape through callbacks
Fixes radar://10973977.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156215 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-04 22:18:39 +00:00
Anna Zaks f132ba8e57 [analyzer] One more pointer escape test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156214 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-04 22:18:36 +00:00
Ted Kremenek 85d87df66a Explicitly model capturing variables for blocks in the static analyzer. Fixes <rdar://problem/11125868>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156211 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-04 21:48:42 +00:00
Anna Zaks 84d43848e3 [analyzer]Fixup r156134: Handle the case when FunctionDecl isn't avail.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156183 91177308-0d34-0410-b5e6-96231b3b80d8
2012-05-04 17:37:16 +00:00