Douglas Gregor
30e631862f
Revert r100008, which inexplicably breaks the clang-i686-darwin10 builder
...
llvm-svn: 100018
2010-03-31 17:25:35 +00:00
Douglas Gregor
3baad0d4f7
Rename CodeModificationHint to FixItHint, since we've been using the
...
term "fix-it" everywhere and even *I* get tired of long names
sometimes. No functionality change.
llvm-svn: 100008
2010-03-31 15:31:50 +00:00
John McCall
d9c7c6568e
Introduce a new kind of derived-to-base cast which bypasses the need for
...
null checks, and make sure we elide null checks when accessing base class
members.
llvm-svn: 99963
2010-03-30 23:58:03 +00:00
Ted Kremenek
2d107f9d1d
RegionStore: specially handle loads from integer global variables declared 'const'.
...
Fixes a false positive reported in PR 6288.
llvm-svn: 99922
2010-03-30 20:31:04 +00:00
Ted Kremenek
f7c226da00
Use 'const Optional<SVal>&' to avoid an extra copy.
...
llvm-svn: 99921
2010-03-30 20:30:52 +00:00
Rafael Espindola
c50c27cca8
the big refactoring bits of PR3782.
...
This introduces FunctionType::ExtInfo to hold the calling convention and the
noreturn attribute. The next patch will extend it to include the regparm
attribute and fix the bug.
llvm-svn: 99920
2010-03-30 20:24:48 +00:00
Ted Kremenek
4be6a75884
Change the analyzer to recognize (but ignore) assignments to isa. Fixes PR 6302.
...
llvm-svn: 99904
2010-03-30 18:24:54 +00:00
Rafael Espindola
8756268ee5
Be a bit more consistent in using operator->
...
This patch moves some methods from QualType to Type and changes the users to
use -> instead of .
llvm-svn: 99805
2010-03-29 03:39:46 +00:00
Benjamin Kramer
c048322523
Checker: random include cleanup.
...
llvm-svn: 99731
2010-03-27 21:19:47 +00:00
Ted Kremenek
0f250e4c5b
Fix NoReturnFunctionChecker to properly look at a function's type
...
when determining if it returns. Fixes <rdar://problem/7796563>.
llvm-svn: 99663
2010-03-26 22:57:13 +00:00
Zhongxing Xu
b6e1c13c36
Add methods to remove a GDM entry.
...
Instead of setting the ReturnExpr GDM to NULL, remove it.
llvm-svn: 99470
2010-03-25 01:39:39 +00:00
Ted Kremenek
8edc6dfd20
Use llvm::SmallString instead of std::string.
...
llvm-svn: 99442
2010-03-24 22:39:47 +00:00
Ted Kremenek
aeaf3d2ce6
Improve static analyzer diagnostic concerning the use of 'mktemp'
...
llvm-svn: 99441
2010-03-24 22:39:45 +00:00
Zhongxing Xu
e248dca300
Bind the constructed object value to CXXConstructExpr.
...
llvm-svn: 99271
2010-03-23 09:13:17 +00:00
Zhongxing Xu
b473f91498
update CMakeLists.txt
...
llvm-svn: 99269
2010-03-23 08:14:19 +00:00
Zhongxing Xu
bf2f0d74a2
Clear the return expr GDM after using it.
...
llvm-svn: 99268
2010-03-23 08:09:29 +00:00
Zhongxing Xu
1ff3dcef1f
Add a AggExprVisitor class. It contains lots of boiler
...
plate code for evaluating expressions of C++ class type.
llvm-svn: 99267
2010-03-23 07:32:14 +00:00
Zhongxing Xu
7fffbcc756
merge line.
...
llvm-svn: 99259
2010-03-23 05:13:26 +00:00
Zhongxing Xu
3c0c81a4d4
Since we now may have basicblocks with the same block is in different function,
...
change the block counter map from unsigned -> unsigned to
<StackFrameContext*, unsigned> -> unsigned.
llvm-svn: 99255
2010-03-23 05:05:02 +00:00
Ted Kremenek
bb6f5af4a4
Tweak null dereference diagnostics to give clearer diagnostics when
...
a null dereference results from a field access.
llvm-svn: 99236
2010-03-23 01:11:38 +00:00
Ted Kremenek
28ec56d7dd
Improve the diagnostics for the UndefinedAssignmentChecker when an
...
uninitialized value is used in the LHS of a compound assignment.
llvm-svn: 99221
2010-03-22 22:16:26 +00:00
Kovarththanan Rajaratnam
a6405f7a95
Sort calls to add_clang_library()
...
llvm-svn: 99191
2010-03-22 18:16:06 +00:00
Ted Kremenek
bf1dbf37e7
Delete the new visitor if an old one already exists.
...
llvm-svn: 99114
2010-03-21 04:38:40 +00:00
Ted Kremenek
3460b539df
Reapply r99024 (but with the memory issue now fixed).
...
llvm-svn: 99064
2010-03-20 18:02:01 +00:00
Ted Kremenek
92713e7ec3
Check if a BugReporterVisitor has already been added to a BugReporterContext.
...
This avoids redundant diagnostics.
llvm-svn: 99063
2010-03-20 18:01:57 +00:00
Daniel Dunbar
4e3e0991e9
Revert r99024, "Augment path diagnostics to include displaying when a message
...
expression", statistical evidence indicates it has some kind of memory error.
llvm-svn: 99040
2010-03-20 04:28:39 +00:00
Ted Kremenek
8a8e3e61aa
Augment path diagnostics to include displaying when a message expression
...
is not evaluated because the receiver is nil.
llvm-svn: 99024
2010-03-20 01:17:30 +00:00
Ted Kremenek
c342c9c001
Refactor argument checking in CallAndMessageChecker to be the same
...
for both CallExprs and ObjCMessageExprs.
llvm-svn: 98800
2010-03-18 03:22:29 +00:00
Ted Kremenek
9c05f4ef69
Detect pass-by-value arguments that are structs that contain
...
uninitialized data.
llvm-svn: 98796
2010-03-18 02:17:27 +00:00
Ted Kremenek
e174fda979
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.
llvm-svn: 98795
2010-03-18 01:22:39 +00:00
Zhongxing Xu
03fd76663e
Mark CXXThisRegion in the current or parent stack frame context as live so that
...
their bindings are not removed.
llvm-svn: 98705
2010-03-17 03:35:08 +00:00
Zhongxing Xu
0eb690390d
Add VisitCXXContructExpr logic to the analyzer. This still has not fully worked
...
since RemoveDeadBinding mistakenly remove the binding to CXXThisRegion.
llvm-svn: 98629
2010-03-16 13:14:16 +00:00
Jeffrey Yasskin
f6442f80cb
Allow users to set CPPFLAGS and CXXFLAGS on the make command line.
...
Tested: make CPPFLAGS=-m64 CXXFLAGS=-m64 -j8 && (cd tools/clang;make test)
llvm-svn: 98399
2010-03-12 22:55:16 +00:00
Ted Kremenek
1794ec4a30
Simplify assertion.
...
llvm-svn: 98176
2010-03-10 19:09:37 +00:00
Ted Kremenek
fe697ebaaf
Remove '#if 0' code. Lazy compound values have proven their worth.
...
llvm-svn: 98175
2010-03-10 19:09:34 +00:00
Ted Kremenek
9e92d3f99d
Remove the subregion map cache. It is no longer used.
...
llvm-svn: 98161
2010-03-10 16:38:44 +00:00
Ted Kremenek
2ce82b2323
Fix stale comment.
...
llvm-svn: 98160
2010-03-10 16:38:41 +00:00
Ted Kremenek
ddce4a3d0f
Really apply (unnoticed weird git-svn merge conflict in 98144): Refactor RegionStore::RemoveDeadBindings to use the same core cluster analysis algorithm as RegionStore::InvalidateRegions().
...
Beyond simplifying the algorithm significantly, we no longer
need to build subregion maps in RemoveDeadBindings(). This
and other changes cause a significant speedup: the time to
analyze sqlite3.c (single core) drops by 14%.
llvm-svn: 98159
2010-03-10 16:32:56 +00:00
Ted Kremenek
ba2e6c6b73
Refactor RegionStore::RemoveDeadBindings to use the same core
...
cluster analysis algorithm as RegionStore::InvalidateRegions().
Beyond simplifying the algorithm significantly, we no longer
need to build subregion maps in RemoveDeadBindings(). This
and other changes cause a significant speedup: the time to
analyze sqlite3.c (single core) drops by 14%.
llvm-svn: 98144
2010-03-10 07:20:03 +00:00
Ted Kremenek
a2536b642c
Refactor some of RegionStore's InvalidateRegionsWorker class
...
into a 'ClusterAnalysis' parent class. The idea is
to potentially reuse this for reworking RemoveDeadBindings.
llvm-svn: 98143
2010-03-10 07:19:59 +00:00
Zhongxing Xu
1bb6a1a593
Add use-after-free check to MallocChecker.
...
llvm-svn: 98136
2010-03-10 04:58:55 +00:00
Ted Kremenek
7de5f32479
Enhance basic store to also lazily symbolicate VarRegions
...
with an 'unknown' memory space.
llvm-svn: 98110
2010-03-10 00:18:08 +00:00
Douglas Gregor
de4827dd34
Extend ObjCMessageExpr for class method sends with the source location
...
of the class name.
llvm-svn: 97943
2010-03-08 16:40:19 +00:00
Duncan Sands
7a9ba76825
Remove unused headers.
...
llvm-svn: 97941
2010-03-08 11:29:03 +00:00
Zhongxing Xu
e73584384a
Remove reference to AnalysisContext in Environment. We already have LocationContext
...
information in ExplodedNode.
llvm-svn: 97785
2010-03-05 04:45:36 +00:00
Zhongxing Xu
5cb8d9d40f
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.
llvm-svn: 97724
2010-03-04 09:04:52 +00:00
Ted Kremenek
5d2bb1b9b3
[CFG]
...
After discussion with Zhongxing, don't force the initializer of DeclStmts to be
block-level expressions.
This led to some interesting fallout:
[UninitializedValues]
Always visit the initializer of DeclStmts (do not assume they are block-level expressions).
[BasicStore]
With initializers of DeclStmts no longer block-level expressions, this causes self-referencing initializers (e.g. 'int x = x') to no longer cause the initialized variable to be live before the DeclStmt. While this is correct, it caused BasicStore::RemoveDeadBindings() to prune off the values of these variables from the initial store (where they are set to uninitialized). The fix is to back-port some (and only some) of the lazy-binding logic from RegionStore to
BasicStore. Now the default values of local variables are determined lazily as opposed
to explicitly initialized.
llvm-svn: 97591
2010-03-02 21:43:54 +00:00
Ted Kremenek
c3c1b10243
Don't conjure a symbol for DeclStmts when the variable is a C++ reference.
...
llvm-svn: 97590
2010-03-02 21:43:52 +00:00
Zhongxing Xu
6d3cc382df
Since now we store the cast type with an ElementRegion, there is
...
no need to store a type with SymbolRegionValue.
llvm-svn: 97437
2010-03-01 06:56:52 +00:00
Zhongxing Xu
b0e5c27113
Assert when loading from a code text region instead of returning an unknown silently.
...
llvm-svn: 97436
2010-03-01 05:29:02 +00:00
Zhongxing Xu
7ba9e99015
Use getBody() to get the function definition when the decl referenced is not
...
definition.
llvm-svn: 97373
2010-02-28 06:39:11 +00:00
Zhongxing Xu
5c07584f44
Use a GDM to record the returned expression in the state when VisitReturnStmt.
...
Use this information to find the returned value and bind it to CallExpr in
ProcessCallExit.
And there is no need to remove dead bindings in ProcessCallExit, because
a. it would clean up the return value bound to CallExpr
b. we still would do it in the next ProcessStmt(), where we would not misclean
up the return value.
llvm-svn: 97225
2010-02-26 15:43:34 +00:00
Zhongxing Xu
d041bc6ff4
Remove derelict GRStmtNodeBuilder::LastNode.
...
llvm-svn: 97207
2010-02-26 02:38:09 +00:00
Douglas Gregor
a2fbc94458
Restore Zhongxing's commits r97122 r97127 r97129 r97131 which were reverted due to a Clang-on-Clang failure
...
llvm-svn: 97162
2010-02-25 19:01:53 +00:00
Jakob Stoklund Olesen
5a8f9acaa8
Revert patches r97122 r97127 r97129 r97131.
...
They were breaking clang-x86_64-darwin10-selfhost
llvm-svn: 97138
2010-02-25 15:47:53 +00:00
Zhongxing Xu
ee29cc3b66
Move the GenerateCallExitNode logic completely into GREndPathNodeBuilder.
...
llvm-svn: 97131
2010-02-25 07:57:35 +00:00
Zhongxing Xu
9516feac36
Move the dead bindings removal logic from CallInliner to GRExprEngine::ProcessCallExit().
...
llvm-svn: 97129
2010-02-25 07:36:34 +00:00
Zhongxing Xu
2fa52b06d0
Add comments.
...
llvm-svn: 97127
2010-02-25 07:03:08 +00:00
Zhongxing Xu
14863610f9
Call inliner improvements:
...
This patch implements the CallEnter/CallExit idea of Ted.
Add two interfaces to GRSubEngine: ProcessCallEnter, ProcessCallExit.
The CallEnter program point uses caller's location context. The
CallExit program point uses callee's location context.
CallEnter is built by GRStmtNodeBuilder. CallExit is built by
GREndPathNodeBuilder.
llvm-svn: 97122
2010-02-25 06:46:30 +00:00
Ted Kremenek
b663ffe5f8
Add MacOSXAPIChecker, a meta checker to include various precondition checks for calls
...
to various MacOS X functions. The checks in BasicObjCFoundationChecks.cpp will
gradually be migrated here.
As a first check, check that when 'dispatch_once()' is passed a predicate value
that has non-local storage.
llvm-svn: 97116
2010-02-25 05:44:09 +00:00
Ted Kremenek
5563dea713
When generating error node, check to see if we already cached out.
...
llvm-svn: 97115
2010-02-25 05:44:05 +00:00
Ted Kremenek
d98d22b9af
Enhance the unused ivar checker to not consider an ivar to be accidentally unused
...
when it is explicitly marked as unused via __attribute__((unused)).
llvm-svn: 97104
2010-02-25 03:26:55 +00:00
Ted Kremenek
d55522f02e
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.
llvm-svn: 97086
2010-02-25 00:20:35 +00:00
Ted Kremenek
bfe9f5f4db
Remove stray #include.
...
llvm-svn: 97085
2010-02-25 00:20:31 +00:00
Ted Kremenek
ad744f4b88
Remove #include.
...
llvm-svn: 97084
2010-02-25 00:20:28 +00:00
Ted Kremenek
11e899c199
Divide list of registration functions in API and foundational checks. Also trim whitespace.
...
llvm-svn: 97083
2010-02-25 00:20:25 +00:00
Ted Kremenek
43fddf77a4
Sort list of checker registration functions.
...
llvm-svn: 97082
2010-02-25 00:20:22 +00:00
Ted Kremenek
b4331a9908
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>.
llvm-svn: 96985
2010-02-23 21:19:33 +00:00
Ted Kremenek
1fcc56c57a
Recognize attributes ns_returns_not_retained and cf_returns_not_retained
...
in the static analyzer.
llvm-svn: 96539
2010-02-18 00:06:12 +00:00
Ted Kremenek
2b36f3f666
Sort @includes.
...
llvm-svn: 96537
2010-02-18 00:05:58 +00:00
Zhongxing Xu
b2ef2f1427
In symbol reaper, a variable is live if its stack frame is the parent of the
...
current stack frame.
When leaving a callee, remove all bindings belonging to that callee.
llvm-svn: 96473
2010-02-17 08:50:05 +00:00
Zhongxing Xu
daf4616455
For inline-based inter-procedural analysis, we will have multiple stack space regions. Use a dense map to store them.
...
llvm-svn: 96472
2010-02-17 08:46:50 +00:00
Ted Kremenek
228639746a
Add simpler checker to check if variables captured by a block are uninitialized.
...
llvm-svn: 96341
2010-02-16 08:33:59 +00:00
Ted Kremenek
d51217e968
Convert GRExprEngine's handling of ObjCMessageExprs to use a worklist
...
to evaluate arguments.
llvm-svn: 96293
2010-02-15 23:02:46 +00:00
Ted Kremenek
4ba99bee2a
clang::Attr objects should be treated as AST nodes as well by
...
the LLVMConventionsChecker.
llvm-svn: 96202
2010-02-14 22:58:16 +00:00
Ted Kremenek
4853131459
Add LLVM conventions check that scans for AST elements (types, stmts, decls)
...
that allocate heap memory.
llvm-svn: 96184
2010-02-14 19:09:13 +00:00
Ted Kremenek
988805c81e
Change LLVMConventionsChecker to accept an entire translation unit instead
...
of operating on each code decl. This exposes two flaws in AnalysisConsumer
that should eventually be fixed:
(1) It is not possible to associate multiple "actions" with a single
command line argument. This will require the notion of an
"analysis" group, and possibly tablegen support. (although eventually
we want to support dynamically loading analyses as well)
(2) AnalysisConsumer may not actually be scanning the declarations in namespaces.
We'll experiment first in LLVMConventionsChecker before changing the
behavior in AnalysisConsumer.
llvm-svn: 96183
2010-02-14 19:09:05 +00:00
Ted Kremenek
c968e5e9b9
For the StringRef check, also visit the children of DeclStmts.
...
llvm-svn: 96181
2010-02-14 19:08:43 +00:00
Ted Kremenek
4806a833a7
Place type-checking static methods at type of file (where they will congregate).
...
No functionality change.
llvm-svn: 96180
2010-02-14 19:08:36 +00:00
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