Richard Smith
caf3390d44
Constant expression evaluation refactoring:
...
- Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions,
and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert
behaviour.
- Factor out evaluation of bitfield bit widths.
- Fix a few places which would evaluate an expression twice: once to determine
whether it is a constant expression, then again to get the value.
llvm-svn: 141561
2011-10-10 18:28:20 +00:00
Ted Kremenek
d79719b144
Provide basic static analyzer support for CXXTemporaryObjectExpr. Patch by Jim Goodnow II.
...
llvm-svn: 141433
2011-10-07 22:48:13 +00:00
Ted Kremenek
dccc2b2277
Remove AnalysisContext::getLiveVariables(), and introduce a templatized mechanism to lazily create analyses that are attached to AnalysisContext objects.
...
llvm-svn: 141425
2011-10-07 22:21:02 +00:00
Anna Zaks
754eafb765
[analyzer] Previously, we were passing to CheckerContext enough info to construct ProgramPoint and it would pass it to NodeBuilder, which in turn would construct the ProgramPoint. Simplify it by just passing the ProgramPoint to CheckerContext. The ProgramPoint can only change if a checker tags it, in which case, we create a copy with the given tag.
...
(A step closer to making CheckerContext work with all node builders, not only StmtNodeBuilder.)
llvm-svn: 141417
2011-10-07 21:52:33 +00:00
Anna Zaks
8de8cfdd21
ProgramPoint cleanup after the previous commit r141408 (remove the copy constructor, mark withTag const).
...
Move getProgramPoint() utility from CoreEngine.cpp into ProgramPoint.
llvm-svn: 141414
2011-10-07 21:01:38 +00:00
John McCall
f937c023bf
Rename TagDecl::isDefinition -> isCompleteDefinition
...
for better self-documenting code, since the semantics
are subtly different from getDefinition().
llvm-svn: 141355
2011-10-07 06:10:15 +00:00
Ted Kremenek
b7531d622d
[static analyzer] Fix crash in LiveVariables and Environment::getSVal() when analyzing C++ pointer-to-member calls. Fixes <rdar://problem/10243398>.
...
llvm-svn: 141312
2011-10-06 20:53:28 +00:00
Peter Collingbourne
d937a99465
Clang-side build system infrastructure for multiple tblgens.
...
llvm-svn: 141267
2011-10-06 01:52:10 +00:00
Anna Zaks
3e0f415d0d
[analyzer] Remove the dependency on CheckerContext::getStmt() as well as the method itself.
...
llvm-svn: 141262
2011-10-06 00:43:15 +00:00
Ted Kremenek
f3e3f6645e
Fix major regression in RetainCountChecker. DefaultSummaries were not being used when they were meant to be. Fixes <rdar://problem/10241614>.
...
llvm-svn: 141250
2011-10-05 23:54:29 +00:00
Anna Zaks
c4aa22cdd4
[analyzer] Remove the last dependency on CheckerContext::getNodeBuilder() as well as the method itself.
...
Checkers should not directly access NodeBuilder, nodes can be created by calling the CheckerContext's generateNode() methods.
llvm-svn: 141249
2011-10-05 23:44:11 +00:00
Anna Zaks
77f8661d18
[analyzer] OSAtomicChecker implements evalCall in a very invasive way - it essentially simulates inlining of compareAndSwap() by means of setting the NodeBuilder flags and calling ExprEngine directly.
...
This commit introduces a new callback just for this checker to unblock checker API cleanup.
llvm-svn: 141246
2011-10-05 23:37:30 +00:00
Anna Zaks
8569d2d8f2
[analyzer] Removing more references to CheckerContext::getNodeBuilder(): ask CheckerContext to generate the nodes.
...
llvm-svn: 141136
2011-10-04 23:29:16 +00:00
Anna Zaks
23d7ba3579
[analyzer] Removing references to CheckerContext::getNodeBuilder(): checkers can obtain block count directly from the Context.
...
llvm-svn: 141112
2011-10-04 20:43:05 +00:00
Anna Zaks
c76ec12ccf
[analyzer] Remove unused methods, add comments to others.
...
llvm-svn: 141098
2011-10-04 18:34:40 +00:00
Anna Zaks
208d54ce09
[analyzer] Remove redundant state (AnalysisContext pointer for every BinaryOperator tracked) from IdempotentOperationChecker.
...
llvm-svn: 141045
2011-10-03 23:07:13 +00:00
Anna Zaks
892427e2fa
[analyzer] In UndefBranchChecker, use a node generator which does not create an edge/branching. (ExprEngine should be in charge of generating edges. The checkers should examine the condition and generate PostCondition node if needed.)
...
llvm-svn: 141034
2011-10-03 21:55:56 +00:00
Anna Zaks
c42197d0f8
[analyzer] Cleanup in UndefBranchChecker:
...
- Remove unused FindUndefExpr::ProgramStateManager.
- The Condition parameter of the callback is the terminator of the block, no need to retrieve it again.
llvm-svn: 141027
2011-10-03 21:16:32 +00:00
Argyrios Kyrtzidis
b8c3aaf479
Allow getting all source locations of selector identifiers in a ObjCMethodDecl.
...
Instead of always storing all source locations for the selector identifiers
we check whether all the identifiers are in a "standard" position; "standard" position is
-Immediately before the arguments: -(id)first:(int)x second:(int)y;
-With a space between the arguments: -(id)first: (int)x second: (int)y;
-For nullary selectors, immediately before ';': -(void)release;
In such cases we infer the locations instead of storing them.
llvm-svn: 140989
2011-10-03 06:37:04 +00:00
Ted Kremenek
2a14c695eb
Fix LiveVariables analysis bug with MaterializeTemporaryExpr and fix handling in ExprEngine. Fixes <rdar://problem/10201666>.
...
llvm-svn: 140956
2011-10-02 00:54:48 +00:00
Anna Zaks
79ada929b7
Address PR10616. The crash has already been fixed by Ted in r140725, so just refactor to use existing API + test case.
...
llvm-svn: 140932
2011-10-01 06:35:19 +00:00
John McCall
525f05597f
Tweak the interface for analyzing the CF conventions for a name
...
to take a FunctionDecl* instead of an llvm::StringRef. Eventually
we might push more logic in there, like using slightly different
conventions for C++ methods.
Also, fix a bug where 'copy' and 'create' were being caught in
non-camel-cased strings. We want copyFoo and CopyFoo and XCopy
but not Xcopy or xcopy.
llvm-svn: 140911
2011-10-01 00:48:56 +00:00
Ted Kremenek
afedc07a9b
Fix crash when analyzing C++ code involving constant enums and switch statements (<rdar://problem/10202899>).
...
llvm-svn: 140844
2011-09-30 03:51:54 +00:00
Anna Zaks
819b0d8619
[analyzer] Fix a bug in RetainReleaseChecker diagnostics. It gives more precise error message on the modified test case (and prevents duplicate diagnostics when we purge at block granularity).
...
llvm-svn: 140840
2011-09-30 02:19:19 +00:00
Anna Zaks
8d4c8e1498
[analyzer] Add -analyzer-purge option which can take on multiple values, remove -analyzer-purge=none. (Small refactor as well: move the work of constructing AnalysisManager from the callers to the class itself.)
...
llvm-svn: 140838
2011-09-30 02:03:00 +00:00
Ted Kremenek
252e03596a
Check for empty predecessors for walking them.
...
llvm-svn: 140725
2011-09-28 21:20:00 +00:00
Anna Zaks
0070c6d4db
Fix a crash in MallocOverflowSecurityChecker. Patch by Lei Zhang.
...
llvm-svn: 140648
2011-09-27 22:25:01 +00:00
David Blaikie
0cc494361c
Renaming PathDiagnosticClients.h to PathDiagnosticConsumers.h (issue 5397)
...
llvm-svn: 140596
2011-09-27 01:43:33 +00:00
David Blaikie
53c125d063
Rename PathDiagnosticClient to PathDiagnosticConsumer as per issue 5397
...
llvm-svn: 140492
2011-09-26 00:51:36 +00:00
David Blaikie
9c902b5502
Rename Diagnostic to DiagnosticsEngine as per issue 5397
...
llvm-svn: 140478
2011-09-25 23:23:43 +00:00
Benjamin Kramer
1f88d2f531
Fix comment typo.
...
Patch by Rui Paulo!
llvm-svn: 140448
2011-09-24 03:04:03 +00:00
David Blaikie
aa347f9392
Removing a bunch of dead returns/breaks after llvm_unreachables.
...
llvm-svn: 140407
2011-09-23 20:26:49 +00:00
Anna Zaks
ff7da05670
Move immutable map canonization out of the removeDeadBindings loop (via using ImmutableMapRef). Gives ~2% speedup.
...
llvm-svn: 140403
2011-09-23 19:14:09 +00:00
David Blaikie
83d382b1ca
Switch assert(0/false) llvm_unreachable.
...
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Anna Zaks
9db35a8750
ST->scanReachableSymbols() is creating a SubRegionMap (SRM) on every call since one SRM is created in each ScanReachableSymbols instance. Creating the object just once and calling only scan inside the loop gives ~ 14% speed up of the StaticAnalyzer run (Release+Asserts).
...
Pull out the declaration of the ScanReachableSymbols so that it can be used directly. Document ProgramState::scanReachableSymbols() methods.
llvm-svn: 140323
2011-09-22 18:10:41 +00:00
Anna Zaks
15ca5e7a21
[analyzer] Fix a bug where PathDiagnosticLocation did not generate a valid range and add asserts to check validity of locations early on. Ignore invalid ranges in PathDiagnosticPiece (they could be added by checker writers).
...
Addresses radar://10124836 and radar://radar10102244.
llvm-svn: 140218
2011-09-21 00:35:58 +00:00
Anna Zaks
d70da08160
[analyzer] Refactor PathDiagnosticLocation: Remove SourceRange member from PathDiagnosticLocation - FullSourceLoc Loc and PathDiagnosticRange Range are sufficient.
...
llvm-svn: 140206
2011-09-20 23:27:32 +00:00
Anna Zaks
6800ab437c
[analyzer] Remove dead code. (This code is trying to implement the idea that PathDiagnosticClient could implement DiagnosticClient and has been dead for a while).
...
llvm-svn: 140198
2011-09-20 22:30:48 +00:00
Anna Zaks
c29bed3989
[analyzer] Refactor PathDiagnosticLocation: Make PathDiagnosticLocation(SourceLocation...) private. Most of the effort here goes to making BugReport refer to a PathDiagnosticLocation instead of FullSourceLocation.
...
(Another step closer to the goal of having Diagnostics which can recover from invalid SourceLocations.)
llvm-svn: 140182
2011-09-20 21:38:35 +00:00
Anna Zaks
b2dfc2b7be
[analyzer] Refactor PathDiagnosticLocation: Use the pre-computed Range and Location for profile.
...
llvm-svn: 140180
2011-09-20 21:25:00 +00:00
Anna Zaks
83128bc101
[analyzer] Refactor PathDiagnosticLocation: Use PointerUnion of LocationContext and AnalysisContext to support creation of PathDiagnosticLocations for checkers which no context sensitivity.
...
llvm-svn: 140162
2011-09-20 18:23:52 +00:00
Anna Zaks
de03d72a7b
[analyzer] Refactor PathDiagnosticLocation: Lazily query LocationContext for a ParentMap as needed.
...
llvm-svn: 140147
2011-09-20 16:37:36 +00:00
Anna Zaks
22fec1c4d9
[analyzer] Remove LocationContext and a dependency from PathDiagnosticLoaction.
...
llvm-svn: 140146
2011-09-20 16:23:37 +00:00
Anna Zaks
745486a5da
[analyzer] Refactor PathDiagnosticLocation: Pre-compute Range and Location with gen methods on object creation instead of computing on demand. This would allow to remove dependency on the other members which help with construction and might not even be valid at later stages (to be removed later on).
...
llvm-svn: 140131
2011-09-20 01:51:40 +00:00
Anna Zaks
de8c5eddb9
[analyzer] Use more create methods in the PathDiagnostic, cleanup.
...
llvm-svn: 140130
2011-09-20 01:38:47 +00:00
Anna Zaks
6e76384c82
[analyzer] BugReport has a profile method, so reuse it here.
...
llvm-svn: 140100
2011-09-19 23:44:31 +00:00
Argyrios Kyrtzidis
e6e67deeed
Rename SourceLocation::getFileLocWithOffset -> getLocWithOffset.
...
It already works (and is useful with) macro locs as well.
llvm-svn: 140057
2011-09-19 20:40:19 +00:00
Anna Zaks
efd182d992
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 5 of ?):
...
- Get rid of PathDiagnosticLocation(SourceRange r,..) constructor by providing a bunch of create methods.
- The PathDiagnosticLocation(SourceLocation L,..), which is used by crate methods, will eventually become private.
- Test difference is in the case when the report starts at the beginning of the function. We used to represent that point as a range of the very first token in the first statement. Now, it's just a single location representing the first character of the first statement.
llvm-svn: 139932
2011-09-16 19:18:30 +00:00
Anna Zaks
207c68012a
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 4 of ?):
...
- The closing brace is always a single location, not a range.
- The test case previously had a location key 57:1 followed by a range [57:1 - 57:1].
llvm-svn: 139832
2011-09-15 20:06:34 +00:00
Anna Zaks
921f04924f
[analyzer] Refactor: make PathDiagnosticLocation responsible for validation of SourceLocations (commit 2 of ?):
...
- Fix a fixme and move the logic of creating a PathDiagnosticLocation corresponding to a ProgramPoint into a PathDiagnosticLocation constructor.
- Rename PathDiagnosticLocation::create to differentiate from the added constructor.
llvm-svn: 139825
2011-09-15 18:56:07 +00:00