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

108 Коммитов

Автор SHA1 Сообщение Дата
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
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
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 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 95a011204f Specially handle casts to 'void' in AdjustedReturnValueChecker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95287 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 04:18:55 +00:00
Ted Kremenek 40c37e1a62 static analyzer: handle casts of a function to a function pointer with
a different return type.  While we don't emit any errors (yet), at
least we avoid cases where we might crash because of an assertion
failure later on (when the return type differs from what is expected).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95268 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04 00:47:48 +00:00
Ted Kremenek 5b290658c5 Fix regression in RegionStore due to recent changes in
RegionStoreManager::InvalidateRegions() by adjusting the worklist to
iterate over BindingKeys instead of MemRegions.  We also only need to
do the actual invalidation work on base regions, and for non-base
regions just blow away their bindings.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95200 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03 04:16:00 +00:00
Ted Kremenek f68170481d Explicitly check for casts to double or complex types instead of possibly asserting in SValuator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95128 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 21:11:40 +00:00
Ted Kremenek 61e8e1b842 Fix bug in GRExprEngine::VisitSizeOfAlignOfExpr() where we do not add
'Pred' to 'Dst' for cases we currently don't handle.  This fixes
<rdar://problem/7593875>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95048 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02 02:01:51 +00:00
Mike Stump 46171917dc Insulate these from changes to the default for -Wunreachable-code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94326 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23 20:12:18 +00:00
Zhongxing Xu 45eb40641f Add test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93874 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 12:11:55 +00:00
Ted Kremenek c213b48206 Teach BugReporter to "escape" the occurance of '%' characters in diagnostic messages when emitted results to the standard Diagnostics output. Fixes PR 6033.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93507 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 07:56:51 +00:00
Chris Lattner 7ef655a788 implement PR6004, warning about divide and remainder by zero.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93256 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 21:23:57 +00:00
Ted Kremenek 36fcde0ae1 Make sure this test case tests analyzing both x86_64 and i386 archs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93133 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 22:31:25 +00:00
Chris Lattner e030358cc0 add a bunch of missing prototypes to tests
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93072 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 20:43:19 +00:00
Zhongxing Xu 6607aca723 Move test case to a more appropriate file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92725 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 11:49:21 +00:00
Zhongxing Xu 0d1847d79e Add test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92724 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 11:47:58 +00:00
Daniel Dunbar a5728872c7 Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91446 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 20:14:24 +00:00
Zhongxing Xu ef74f4c6dc Replace clang-cc with clang -cc1.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91272 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-14 06:34:20 +00:00
Daniel Dunbar 8a90ac0e85 Normalize options to use '-FOO' instead of '--FOO'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90071 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-29 09:33:10 +00:00
Ted Kremenek 616cf051d4 Tweak UndefBranchChecker to register the most nested "undefined" expression with bugreporter::registerTrackNullOrUndefValue instead of the condition itself.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89682 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-23 18:12:03 +00:00
Ted Kremenek 998c133a3b Cleanup title/description of "undefined branch" BugType and add some test cases for this check.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89679 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-23 17:58:48 +00:00
Ted Kremenek 64fa858556 More checker refactoring. Passing undefined values in a message expression is now handled by UndefinedArgChecker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89519 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-21 00:49:41 +00:00
Fariborz Jahanian 63e963cdff Handle case of missing '@end' in implementation context
gracefully, on par with gcc, by: Issuing a warning,
doing final sematinc check of its definitions and generating
its meta-data.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88934 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-16 18:57:01 +00:00
Ted Kremenek 8382cf57b7 Add clang-cc option "--analyzer-experimental-internal-checks". This
option enables new "internal" checks that will eventually be turned on
by default but still require broader testing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88671 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13 18:46:29 +00:00
Zhongxing Xu d694485f9d Add undefined array subscript checker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86837 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 13:42:54 +00:00
Ted Kremenek de7d800756 CastToStructChecker: use 'isStructureType()' instead of 'isRecordType()' to determine if a pointer is casted to a struct pointer. This fixes an observed false positive when a value is casted to a union.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86813 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11 06:43:42 +00:00
Daniel Dunbar 4fcfde4d5c Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08 01:45:36 +00:00
Ted Kremenek ae78447ef1 Tweak wording and classifications of analyzer diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86127 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05 08:30:12 +00:00
Zhongxing Xu 5206f0b913 Pull VLA size checker into its own files.
Split it to two checkers, one for undefined size, 
the other for zero size, so that we don't need to query the size
when emitting the bug report.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85895 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-03 12:13:38 +00:00
Ted Kremenek 3f214b35ca Fix accidental use of CheckSVal instead of CheckLocation, and add a
small test case to show we handle dereferences of undefined values.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85492 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-29 05:33:39 +00:00
Ted Kremenek 9b02034b64 Fix another static analyzer crash due to a corner case in "folding" symbolic values that are constrained to be a constant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84320 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-17 07:39:35 +00:00
Ted Kremenek b5deae519b Fix static analyzer crash due to recently add symbolic-value constant folding. The issue was falsely
converting the constant value of the LHS of a '<<'/'>>' operation to the same APSInt value of the
RHS.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84269 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-16 20:46:24 +00:00
Ted Kremenek b1d042212f Fix crash introduced by r83358 where a symbol could be eagerly
evaluated to an APSInt with a different bitwidth than the other
operand in a binary expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83368 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-06 03:44:49 +00:00
Ted Kremenek 022a1253c0 Added test case for <rdar://problem/7152418>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82866 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26 17:18:44 +00:00
Ted Kremenek 657406dd40 Fix PR 4988 by removing an invalid assertion (a function can be referenced in
GRExprEngine::VisitDeclRefExpr without 'asLValue' being true).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82598 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-23 01:30:01 +00:00
Ted Kremenek cf54959eae Fix: <rdar://problem/7242006> [RegionStore] compound literal assignment with floats not honored
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82575 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 21:19:14 +00:00
Ted Kremenek cc969fd836 Fix: <rdar://problem/7242015> [RegionStore] variable passed-by-reference (via integer) to function call not invalidated
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82523 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-22 04:48:39 +00:00
Ted Kremenek c32b24452e Add test case for <rdar://problem/6829164>, which was implicitly fixed in r79694.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82495 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-21 23:22:11 +00:00
Ted Kremenek e0a58073b7 Re-introduce diagnostic caching in BugReporter that was originally added in
r82198 and then reverted. This is an intermediate solution, as diagnostic
caching should not rely on static variables.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82301 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 22:37:37 +00:00
Ted Kremenek 7f473c5466 Revert most of r82198, which was causing a large number of crashes
when running the analyzer on real projects.  We'll keep the change to
AnalysisManager.cpp in r82198 so that -fobjc-gc analyzes code
correctly in both GC and non-GC modes, although this may emit two
diagnostics for each bug in some cases (a better solution will come
later).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82201 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 07:31:15 +00:00
Ted Kremenek 6a19832d08 Introduce caching of diagnostics in BugReporter. This provides extra
pruning of diagnostics that may be emitted multiple times.  This is
accomplished by adding FoldingSet profiling support to PathDiagnostic,
and then having BugReporter record what diagnostics have been issued.

This was motived to a serious bug introduced by moving the
'divide-by-zero' checking outside of GRExprEngine into a separate
'Checker' class.  When analyzing code using the '-fobjc-gc' option, a
given function would be analyzed twice, but the second time various
"internal checks" would be disabled to avoid emitting multiple
diagnostics (e.g., "null dereference") for the same issue.  The
problem is that such checks also effect path pruning and don't just
emit diagnostics.  This resulted in an assertion failure involving a
real divide-by-zero in some analyzed code where we would get an
assertion failure in APInt because the 'DivZero' check was disabled
and didn't prune the logic that resulted in the divide-by-zero in the
analyzer.

The implemented solution is somewhat of a hack, and may not perform
extremely well.  This will need to be cleaned up over time.

As a regression test, 'misc-ps.m' has been modified so that its tests
are run using -fobjc-gc to test this diagnostic pruning behavior.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82198 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18 05:37:41 +00:00
Ted Kremenek e2b5744f9a Add static analyzer transfer function support for __builtin_offsetof.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81820 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-15 00:40:32 +00:00
Ted Kremenek cfcd7fd0de Implement: <rdar://problem/7185647> [RegionStore] 'self' cannot be NULL upon entry to a method
Here we implement this as a precondition within GRExprEngine, even though it is
related to how BasicStoreManager and RegionStoreManager model 'self'
differently. Putting this as a high-level precondition is more general, which is
why it isn't in RegionStore.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81378 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-09 20:36:12 +00:00
Ted Kremenek ab2f43cfe7 Fix regression in BasicStoreManager caused by implicitly casting loaded values and trying to load/store from arrays. RegionStoreManager already properly handles these cases well; we just need to gracefully not handle this case in BasicStoreManager. This fixes PR 4781.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80051 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 23:29:04 +00:00
Ted Kremenek 1894dce964 Fix crash reported in <rdar://problem/7124210> by "back-porting" some of the
implicit cast logic in RegionStoreManager to BasicStoreManager. This involved
moving CastRetriedVal from RegionStoreManager to StoreManager.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80026 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-25 20:51:30 +00:00
Ted Kremenek 4ed459851e Fix a bug in RegionStoreSubRegionManager::add() where multiple subregions wouldn't correctly get registered in the SubRegion map.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78162 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 05:31:02 +00:00
Ted Kremenek 8eec7c00e6 Adjust test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78028 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-04 00:58:45 +00:00
Ted Kremenek 48775d5bf0 Add a pass-by-value test for the analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78018 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-03 23:22:53 +00:00