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

743 Коммитов

Автор SHA1 Сообщение Дата
Zhongxing Xu ed8afacb81 Refactor the AnalysisConsumer to analyze functions after the whole
translation unit is parsed. This enables us to inline some calls when still
analyzing one function at a time.

Actions are classified into Function, CXXMethod, ObjCMethod, 
ObjCImplementation.

This does not hurt performance much. The analysis time for sqlite3.c:

before:
real    17m52.440s
user    17m49.460s
sys    0m2.010s

after:
real    18m0.500s
user    17m56.900s
sys    0m2.330s

DisplayProgress option is broken now. -inine-call action is removed. It
will be reenabled in another form, perhaps as an indenpendant option.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102689 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30 04:14:20 +00:00
Ted Kremenek 862b24f8e9 Fix CFG crasher involving statement expressions reported in PR 6938.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102576 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 01:10:26 +00:00
Zhongxing Xu 48fb322305 The second check point in the old test case was invalid.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101983 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21 02:22:25 +00:00
Zhongxing Xu 40ab43b29b Add test cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101878 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20 05:48:57 +00:00
Ted Kremenek d617b85d12 Static analyzer: Don't crash when casting a symbolic region address to a float. Fixes PR 6854.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101499 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16 17:54:33 +00:00
Ted Kremenek 1b49d762e9 Fix PR 6844, a regression caused by the introduction of llvm_unreachable for the default
case in GRExprEngine::Visit (in r101129).  Instead, enumerate all Stmt cases and have
no 'default' case in the switch statement.  When we encounter a Stmt we don't handle,
we should explicitly add it to the switch statement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15 17:33:31 +00:00
Ted Kremenek 115c1b9cc7 Fix CFG bug where bases of member expressions were not always evaluated in a lvalue context. Fixes <rdar://problem/7813989>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11 17:02:10 +00:00
Douglas Gregor d4eea83626 Improve diagnostics when we fail to convert from a source type to a
destination type for initialization, assignment, parameter-passing,
etc. The main issue fixed here is that we used rather confusing
wording for diagnostics such as

t.c:2:9: warning: initializing 'char const [2]' discards qualifiers,
      expected 'char *' [-pedantic]
  char *name = __func__;
        ^      ~~~~~~~~

We're not initializing a 'char const [2]', we're initializing a 'char
*' with an expression of type 'char const [2]'. Similar problems
existed for other diagnostics in this area, so I've normalized them all
with more precise descriptive text to say what we're
initializing/converting/assigning/etc. from and to. The warning for
the code above is now:

t.c:2:9: warning: initializing 'char *' from an expression of type
      'char const [2]' discards qualifiers [-pedantic]
  char *name = __func__;
        ^      ~~~~~~~~

Fixes <rdar://problem/7447179>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100832 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-09 00:35:39 +00:00
Ted Kremenek 99d9838b25 Add static analyzer check for calls to 'pthread_once()' where the control-flow has
automatic storage.  This matches the corresponding check for 'dispatch_once()'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08 19:53:31 +00:00
Chris Lattner 53eee7ba97 Instead of counting totally diagnostics, split the count into a count
of errors and warnings.  This allows us to emit something like this:

2 warnings and 1 error generated.

instead of:

3 diagnostics generated.

This also stops counting 'notes' because they are just follow-on information
about the previous diag, not a diagnostic in themselves.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100675 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-07 18:47:42 +00:00
Ted Kremenek 974d97b251 Fix crash in StoreManager::CastRegion() when the base region is a type with 0 size.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-07 00:46:49 +00:00
Ted Kremenek 68b9a599dd Teach MemRegion::getBaseRegion() about ObjCIvarRegions. We want to treat
them the same way as fields.  This fixes a regression in RegionStore::RemoveDeadbindings()
that emerged from going to the cluster-based analysis.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100570 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-06 22:06:03 +00:00
Zhongxing Xu 7b73b92870 Always assume block-level expressions in the caller are alive when analyzing
the callee.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100429 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05 13:16:29 +00:00
Zhongxing Xu 9618b858e2 Use the element type to compute the array size when the base region is a VarRegion.
Patch by Jordy Rose.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100099 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01 08:20:27 +00:00
Ted Kremenek 75a2d944fc Fix a bug (PR 6699) in RegionStore::RemoveDeadBindings() where
array values with a non-zero offset would get prematurely pruned from the store.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100067 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01 00:15:55 +00:00
Ted Kremenek 4552ff0800 RegionStore: specially handle loads from integer global variables declared 'const'.
Fixes a false positive reported in PR 6288.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99922 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 20:31:04 +00:00
Ted Kremenek 8891c4277a Change the analyzer to recognize (but ignore) assignments to isa. Fixes PR 6302.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99904 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30 18:24:54 +00:00
Fariborz Jahanian 8822f7cda5 Improve diagnostics on incomplete implementation
of objc classes; including which methods
need be implemented and where they come from.
WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99724 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-27 19:02:17 +00:00
Ted Kremenek cfd8ea930a Fix NoReturnFunctionChecker to properly look at a function's type
when determining if it returns.  Fixes <rdar://problem/7796563>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99663 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26 22:57:13 +00:00
Ted Kremenek 452b84ded7 Tweak null dereference diagnostics to give clearer diagnostics when
a null dereference results from a field access.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99236 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23 01:11:38 +00:00
Ted Kremenek 12182a0344 Improve the diagnostics for the UndefinedAssignmentChecker when an
uninitialized value is used in the LHS of a compound assignment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99221 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-22 22:16:26 +00:00
Ted Kremenek 86d07a11f1 Add test case for <rdar://problem/7770737>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98979 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19 19:45:03 +00:00
Ted Kremenek 8133716fc5 Refactor argument checking in CallAndMessageChecker to be the same
for both CallExprs and ObjCMessageExprs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 03:22:29 +00:00
Ted Kremenek 091b588f09 Detect pass-by-value arguments that are structs that contain
uninitialized data.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98796 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 02:17:27 +00:00
Ted Kremenek ebd42f4080 Tweak dead stores checker to not emit a warning when initialization
a scalar variable with a scalar parameter.  This is a
form of defensive programming.  If the variable is unused,
it will be caused by -Wunused-variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18 01:22:39 +00:00
Zhongxing Xu c8023788ac Add use-after-free check to MallocChecker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98136 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 04:58:55 +00:00
Ted Kremenek 2cfe28b6a0 When computing in AnalysisContext the variables referenced
by a block, also look at the contained blocks.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98111 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10 00:18:11 +00:00
Zhongxing Xu 57d3b76761 When profiling Environment, also profile with AnalysisContext*, bacause
we now may have identical states with different analysis context.

Set the right AnalysisContext in state when entering and leaving a callee.

With both of the above changes, we can pass the test case.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97724 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-04 09:04:52 +00:00
Zhongxing Xu 97ccfa599c Add comments to test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97619 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03 01:02:48 +00:00
Zhongxing Xu 15f6b42b68 Register all parameters even if they didn't occur in the function body.
We may query their liveness because they are added to store when passing
argument values.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97562 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02 10:08:30 +00:00
Zhongxing Xu 06079d1d1e Add test case for inlining call analysis.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97300 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27 02:44:37 +00:00
Ted Kremenek e3972a902d Enhance the unused ivar checker to not consider an ivar to be accidentally unused
when it is explicitly marked as unused via __attribute__((unused)).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97104 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 03:26:55 +00:00
Ted Kremenek fc89323210 Remove test case dependancy on platform headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97088 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 01:16:07 +00:00
Ted Kremenek 381d1bf0ee Add UnixAPIChecker, a meta checker to include various precondition checks for calls
to various unix/posix functions, e.g. 'open()'.

As a first check, check that when 'open()' is passed 'O_CREAT' that it has
a third argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25 00:20:35 +00:00
Ted Kremenek 891322002b Dead emit dead store warnings when assigning nil to an ObjC object
pointer (for defensive programming).  This matches the behavior with
assigning NULL to a regular pointer.  Fixes <rdar://problem/7631278>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96985 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 21:19:33 +00:00
Ted Kremenek 786cc72eca Add test case for <rdar://problem/7242010>, which appears to have been fixed
in the recent changes to RegionStore::InvalidateRegions().  Note that we
are still not yet modeling 'memcpy()' explicitly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96902 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23 07:17:57 +00:00
Ted Kremenek 6041111f37 Recognize attributes ns_returns_not_retained and cf_returns_not_retained
in the static analyzer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96539 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18 00:06:12 +00:00
Ted Kremenek 6418825fb8 Add test case showing that a recursive block that captures a block pointer that
isn't marked '__block' is bad.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96357 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 16:55:10 +00:00
Ted Kremenek 94fd0b8c88 Add simpler checker to check if variables captured by a block are uninitialized.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96341 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16 08:33:59 +00:00
Zhongxing Xu 181cc3df6e Fix pr6293. If ptr is NULL, no operation is preformed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96154 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14 06:49:48 +00:00
Ted Kremenek 24c37ad067 Enhance RegionStore::InvalidateRegions() to correctly invalidate bindings
by scanning through the values of LazyCompoundVals.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96067 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-13 01:52:33 +00:00
Ted Kremenek 8ec4aac6d3 Fix lookup of fields from lazy bindings to check if the region is
NULL, not the store, to determine if a lookup succeeded.  The store
can be null if it contained no bindings.  This fixes a false positive
reported to me by a user of the analyzer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95679 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-09 19:11:53 +00:00
Zhongxing Xu 36d02e0984 Add support for binding and retrieving VarRegions in flat store.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95529 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08 05:40:07 +00:00
Ted Kremenek 81861abe9c Also teach RegionStore::RetrieveVar() to handle 'static' pointers that are implicitly initialized to NULL.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95479 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06 04:04:46 +00:00
Ted Kremenek 4dc1566a80 Fix regression in RegionStore (from BasicStore) where static variables were not treated as being implicitly initialized to 0 (and instead were getting symbolicated).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95478 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06 03:57:59 +00:00
Ted Kremenek 85248734f4 Teach RegionStore::InvalidateRegions() to also invalidate static variables referenced by blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95459 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06 00:30:00 +00:00
Ted Kremenek cada305b86 Add test case showing the analyzer invalidates '__block' variables when the block is passed as an argument to an ObjC method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95366 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 06:10:46 +00:00
Ted Kremenek 565e465c6d Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95348 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 02:06:54 +00:00
Ted Kremenek 7909fc8833 Rename -cc1 option '-warn-objc-missing-dealloc' to '-analyzer-check-objc-missing-dealloc'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95347 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:59:21 +00:00
Ted Kremenek fa15be4cf9 Rename -cc1 option '-warn-objc-methodsigs' to '-analyzer-check-objc-methodsigs'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95346 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05 01:57:44 +00:00