Zhongxing Xu
be36ecbb60
Fix pr6293. If ptr is NULL, no operation is preformed.
...
llvm-svn: 96154
2010-02-14 06:49:48 +00:00
Ted Kremenek
184b3383bf
Add new static analyzer for checking LLVM coding conventions: -analyzer-check-llvm-conventions
...
Currently these checks are intended to be largely syntactical, but may get more
sophisticated over time.
As an initial foray into this brave new world, emit a static analyzer warning
when binding a temporary 'std::string' to an 'llvm::StringRef' where the
lifetime of the 'std::string' does not outlive the 'llvm::StringRef'.
llvm-svn: 96147
2010-02-14 02:45:18 +00:00
Ted Kremenek
1a6672a3d4
Enhance RegionStore::InvalidateRegions() to correctly invalidate bindings
...
by scanning through the values of LazyCompoundVals.
llvm-svn: 96067
2010-02-13 01:52:33 +00:00
Ted Kremenek
7950b78430
Pull logic for visiting value bindings in InvalidateRegionsWorker into a separate method.
...
No functionality change.
llvm-svn: 96060
2010-02-13 00:54:03 +00:00
Douglas Gregor
0a5a2216e2
Eliminate the ASTContext parameter from RecordDecl::getDefinition()
...
and CXXRecordDecl::getDefinition(); it's totally unnecessary. No
functionality change.
llvm-svn: 95836
2010-02-11 01:04:33 +00:00
Zhongxing Xu
bc1d4ae206
Add comment.
...
llvm-svn: 95755
2010-02-10 02:02:10 +00:00
Ted Kremenek
499b4e3387
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.
llvm-svn: 95679
2010-02-09 19:11:53 +00:00
Daniel Dunbar
ddf1445134
Fix -Asserts warning.
...
llvm-svn: 95563
2010-02-08 20:24:21 +00:00
Benjamin Kramer
16fe0bcb26
Simplify another switch/strcmp construct. No functionality/performance change.
...
llvm-svn: 95561
2010-02-08 19:51:59 +00:00
Benjamin Kramer
eaabbd8b46
Reapply r95546, no intended change in performance or functionality.
...
llvm-svn: 95552
2010-02-08 18:38:55 +00:00
Ted Kremenek
ac5ab79555
Revert 95546 since it changed the algorithmic characteristics of the convention lookup.
...
llvm-svn: 95547
2010-02-08 16:45:01 +00:00
Benjamin Kramer
30949dd9f9
Simplify code with StringRef.
...
3 files changed, 76 insertions(+), 153 deletions(-)
llvm-svn: 95546
2010-02-08 16:39:00 +00:00
Ted Kremenek
57f0989c16
Revert 95541.
...
llvm-svn: 95545
2010-02-08 16:18:51 +00:00
Zhongxing Xu
500f49fe25
Rename: GRState::getSVal(Stmt*) => getExprVal(),
...
GRState::getSVal(MemRegion*) => Load().
llvm-svn: 95541
2010-02-08 09:30:02 +00:00
Zhongxing Xu
c5f825eacd
BindInternal is redundant. Remove it.
...
llvm-svn: 95540
2010-02-08 08:48:05 +00:00
Zhongxing Xu
8ca2dc05a3
Like for symbolic region, automatically create a element zero region for
...
alloca region.
llvm-svn: 95539
2010-02-08 08:43:02 +00:00
Zhongxing Xu
b02d4a0d11
Unify the implementation of getLValueElement of store managers.
...
It's more sophisticated than the original one of BasicStore. But it does
matter.
llvm-svn: 95536
2010-02-08 08:17:02 +00:00
Zhongxing Xu
f7f0cdc517
Unify the implementation of getLValueIvar and getLValueField of store managers.
...
llvm-svn: 95535
2010-02-08 07:58:06 +00:00
Zhongxing Xu
08515a5242
Move common methods to the base StoreManager class.
...
llvm-svn: 95534
2010-02-08 07:10:35 +00:00
Zhongxing Xu
8ffee4d5f8
ASTContext is now a reference member of StoreManager.
...
llvm-svn: 95531
2010-02-08 06:00:22 +00:00
Zhongxing Xu
000a859f05
Add support for binding and retrieving VarRegions in flat store.
...
llvm-svn: 95529
2010-02-08 05:40:07 +00:00
Ted Kremenek
bdfcacbe8f
Also teach RegionStore::RetrieveVar() to handle 'static' pointers that are implicitly initialized to NULL.
...
llvm-svn: 95479
2010-02-06 04:04:46 +00:00
Ted Kremenek
30fe9ecac2
Fix regression in RegionStore (from BasicStore) where static variables were not treated as being implicitly initialized to 0 (and instead were getting symbolicated).
...
llvm-svn: 95478
2010-02-06 03:57:59 +00:00
Ted Kremenek
5abd69d946
Teach RegionStore::InvalidateRegions() to also invalidate static variables referenced by blocks.
...
llvm-svn: 95459
2010-02-06 00:30:00 +00:00
Zhongxing Xu
ad0ef84040
More GRState* -> Store changes.
...
llvm-svn: 95365
2010-02-05 05:34:29 +00:00
Zhongxing Xu
0d081f373a
Remove unused parameter.
...
llvm-svn: 95364
2010-02-05 05:24:20 +00:00
Zhongxing Xu
f668204a6a
More GRState* -> Store changes.
...
llvm-svn: 95362
2010-02-05 05:18:47 +00:00
Zhongxing Xu
7fcd8acbf8
More GRState* -> Store changes.
...
llvm-svn: 95360
2010-02-05 05:06:13 +00:00
Zhongxing Xu
c7b9f950d7
More GRState* -> Store changes.
...
llvm-svn: 95357
2010-02-05 03:01:53 +00:00
Zhongxing Xu
bd96bf1e78
Change LazyCompoundVal to a <Store, MemRegion*> pair. We really don't need to
...
spread GRState* everywhere.
llvm-svn: 95354
2010-02-05 02:26:30 +00:00
Zhongxing Xu
319deb83d2
Cast evaluation no longer touch GRState.
...
llvm-svn: 95290
2010-02-04 04:56:43 +00:00
Ted Kremenek
49f878524c
Specially handle casts to 'void' in AdjustedReturnValueChecker.
...
llvm-svn: 95287
2010-02-04 04:18:55 +00:00
Ted Kremenek
33617e055a
Remove stray typo.
...
llvm-svn: 95286
2010-02-04 04:14:49 +00:00
Zhongxing Xu
4f8b9899bb
Now that CastRetrievedVal returns SVal, there is no need to use CastResult.
...
llvm-svn: 95279
2010-02-04 02:39:47 +00:00
Ted Kremenek
1e3b95580c
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).
llvm-svn: 95268
2010-02-04 00:47:48 +00:00
Chandler Carruth
54a0f48e0b
Add FlatStore.cpp (from r95214) to CMake build. Don't forget about it! =D
...
llvm-svn: 95215
2010-02-03 09:31:39 +00:00
Zhongxing Xu
5df3f53616
Add skeleton of flat store manager.
...
llvm-svn: 95214
2010-02-03 09:10:32 +00:00
Ted Kremenek
d960564b76
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.
llvm-svn: 95200
2010-02-03 04:16:00 +00:00
Ted Kremenek
64efd0d213
Rework RegionStoreManager's implementation of InvalidateRegions() to
...
not build a subregion map and instead do a single scan of the store.
This is done by building "region clusters" that represent the
collection of regions that have the same base region. Invalidating
any region in a cluster means that they all should get invalidated.
This change brought out a point that Zhongxing mentioned to me
offline: the flattened memory binding has issues distinguishing
between direct and default bindings. For example, setting the default
value for an entire struct is the same as binding to the first
element. To address this problem, I moved the binding "tag" (Direct
or Default) from BindingVal to BdingKey (and removed BindingVal
entirely). This requires us to do double lookups in some cases; and
there is still much more cleanup that can be done.
This change produced a noticeable speedup when analyzing sqlite3 (a
reduction of 4% in running time).
llvm-svn: 95193
2010-02-03 03:06:46 +00:00
Ted Kremenek
b251eb6901
Remove RegionStoreSubRegionMap::iterator and RegionStoreSubRegionMap::begin_end(). This is a precursor to using DenseSet to represent region sets instead of ImmutableSet.
...
llvm-svn: 95151
2010-02-02 22:38:47 +00:00
Ted Kremenek
416b923786
Explicitly check for casts to double or complex types instead of possibly asserting in SValuator.
...
llvm-svn: 95128
2010-02-02 21:11:40 +00:00
Ted Kremenek
fab459fc95
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>.
llvm-svn: 95048
2010-02-02 02:01:51 +00:00
Ted Kremenek
0059c491c1
Hoist diagnostic generation in ReturnStackAddressChecker into a separate method. No functionality change.
...
llvm-svn: 95037
2010-02-02 00:13:41 +00:00
Ted Kremenek
e9918356b2
Move more naming conventions logic out of the retain/release checker to CocoaConventions.h.
...
llvm-svn: 94682
2010-01-27 18:00:17 +00:00
Ted Kremenek
968999b5f6
Add missing call to Optional<...>.getValue() that was pointed out by Chandler.
...
llvm-svn: 94678
2010-01-27 16:31:37 +00:00
Ken Dyck
2c229a7c17
Use getTypeAlignInChars() for alignment in VisitSizeOfAlignOfExpr().
...
llvm-svn: 94677
2010-01-27 12:54:25 +00:00
Ted Kremenek
d5e27af60a
Remove unnecessary ASTContext* argument from isRefType().
...
llvm-svn: 94665
2010-01-27 06:45:10 +00:00
Ted Kremenek
49c0d89a10
Update CMake build.
...
llvm-svn: 94663
2010-01-27 06:14:12 +00:00
Ted Kremenek
db1832d928
Start pulling out pieces of the monolithic retain/release checker into
...
reusable and modular API pieces.
Start by pulling the logic for deriving the Cocoa naming convention
into a separate API, header, and source file.
llvm-svn: 94662
2010-01-27 06:13:48 +00:00
Ted Kremenek
e36bceb97d
Teach RegionStore to handle initialization of incomplete arrays in structures using a compound value. Fixes <rdar://problem/7515938>.
...
llvm-svn: 94622
2010-01-26 23:51:00 +00:00