Commit Graph

109 Commits

Author SHA1 Message Date
Anna Zaks d066f79c80 [analyzer] Unify SymbolVal and SymExprVal under a single SymbolVal
class.

We are going into the direction of handling SymbolData and other SymExpr
uniformly, so it makes less sense to keep two different SVal classes.
For example, the checkers would have to take an extra step to reason
about each type separately.

The classes have the same members, we were just using the SVal kind
field for easy differentiation in 3 switch statements. The switch
statements look more ugly now, but we can make the code more readable in
other ways, for example, moving some code into separate functions.

llvm-svn: 145833
2011-12-05 18:58:30 +00:00
Ted Kremenek 24fc93a940 When analyzing a C++ method (without a specific caller), assume 'this' is non-null. Fixes <rdar://problem/10508787>.
llvm-svn: 145575
2011-12-01 05:29:42 +00:00
Ted Kremenek 61fb647fb4 [static analyzer] be more specific when running removeDeadBindings. Instead of seeing if the predecessor node was a non-StmtPoint, check if it is specifically a BlockEntrance node.
llvm-svn: 144340
2011-11-11 00:10:55 +00:00
Ted Kremenek 20be0b4397 [static analyzer]: only call RemoveDeadBindings() when analyzing non-Expr stmts, entering a basic block, or analyzing non-consumed expressions. This sigificantly speeds up analysis time, and reduces analysis time down to 27% less than before we linearized the CFG.
llvm-svn: 144332
2011-11-10 23:26:10 +00:00
John McCall fe96e0b6be Change the AST representation of operations on Objective-C
property references to use a new PseudoObjectExpr
expression which pairs a syntactic form of the expression
with a set of semantic expressions implementing it.
This should significantly reduce the complexity required
elsewhere in the compiler to deal with these kinds of
expressions (e.g. IR generation's special l-value kind,
the static analyzer's Message abstraction), at the lower
cost of specifically dealing with the odd AST structure
of these expressions.  It should also greatly simplify
efforts to implement similar language features in the
future, most notably Managed C++'s properties and indexed
properties.

Most of the effort here is in dealing with the various
clients of the AST.  I've gone ahead and simplified the
ObjC rewriter's use of properties;  other clients, like
IR-gen and the static analyzer, have all the old
complexity *and* all the new complexity, at least
temporarily.  Many thanks to Ted for writing and advising
on the necessary changes to the static analyzer.

I've xfailed a small diagnostics regression in the static
analyzer at Ted's request.

llvm-svn: 143867
2011-11-06 09:01:30 +00:00
Anna Zaks 49ea5bf562 [analyzer] Make sink attribute part of the node profile.
This prevents caching out on nodes with different sink flag.
(This is a cleaner fix for radar://10376675).

llvm-svn: 143517
2011-11-01 22:41:19 +00:00
Anna Zaks bfb3520fc5 [analyzer] Make sure the child builder use temporary destination sets
The parent and child builders should not share node sets.

llvm-svn: 143515
2011-11-01 22:41:09 +00:00
Anna Zaks 0ec04bf738 [analyzer] Move enqueueEndOfFunction into CoreEngine.
llvm-svn: 143090
2011-10-27 00:59:28 +00:00
Anna Zaks b1d3d96872 [analyzer] Make CoreEngine responsible for enqueueing Stmt Nodes.
Enqueue the nodes generated as the result of processing a statement
inside the Core Engine. This makes sure ExpEngine does not access
CoreEngine's private members and is more concise.

llvm-svn: 143089
2011-10-27 00:59:23 +00:00
Anna Zaks b31d0143dd [analyzer] GenericNodeBuilder -> NodeBuilder.
Remove GenericNodeBuilder and use a class inherited from NodeBuilder instead.

llvm-svn: 143057
2011-10-26 21:06:22 +00:00
Anna Zaks 513921dc8a [analyzer] Remove unused headers.
llvm-svn: 142945
2011-10-25 19:56:58 +00:00
Anna Zaks f380534a1a [analyzer] Make branch for condition callback use CheckerContext
Now, all the path sensitive checkers use CheckerContext!

llvm-svn: 142944
2011-10-25 19:56:54 +00:00
Anna Zaks 3eae33412d [analyze] Convert EndOfPath callback to use CheckerContext
Get rid of the EndOfPathBuilder completely.
Use the generic NodeBuilder to generate nodes.
Enqueue the end of path frontier explicitly.

llvm-svn: 142943
2011-10-25 19:56:48 +00:00
Douglas Gregor deb4a2be67 Implement support for dependent Microsoft __if_exists/__if_not_exists
statements. As noted in the documentation for the AST node, the
semantics of __if_exists/__if_not_exists are somewhat different from
the way Visual C++ implements them, because our parsed-template
representation can't accommodate VC++ semantics without serious
contortions. Hopefully this implementation is "good enough".

llvm-svn: 142901
2011-10-25 01:33:02 +00:00
Anna Zaks e4e5712cd7 [analyzer] Node builders cleanup + comments
Renamed PureNodeBuilder->StmtNodeBuilder.

llvm-svn: 142849
2011-10-24 21:19:59 +00:00
Anna Zaks 4c9169254f [analyzer] Completely remove the global Builder object.
llvm-svn: 142847
2011-10-24 21:19:48 +00:00
Anna Zaks 7b8a2609ff [analyzer] Remove more dependencies from global Builder
- OSAtomicChecker
- ExprEngine::processStmt

llvm-svn: 142846
2011-10-24 21:19:43 +00:00
Anna Zaks e594034f1f [analyzer] Convert ExprEngine::visit() to use short lived builders.
This commit removes the major functional dependency on the ExprEngine::Builder
member variable.

In some cases the code became more verbose. Particularly, we call takeNodes()
and addNodes() to move responsibility for the nodes from one builder to another.
This will get simplified later on.

llvm-svn: 142831
2011-10-24 18:26:19 +00:00
Anna Zaks 5236792019 [analyzer] Convert VisitDeclStmt to use local node builder.
llvm-svn: 142830
2011-10-24 18:26:12 +00:00
Anna Zaks cbdf10be19 [analyzer] Convert more functions (ex:evalBind()) to iterative builders
llvm-svn: 142829
2011-10-24 18:26:08 +00:00
Anna Zaks f011a4a6f9 [analyzer] Convert VisitUnaryOperator to use short lived Node builders
To convert iteratively, we take the nodes the local builder will
process from the from the global builder and add the generated nodes
after the short lived builder is done. PureStmtNodeBuilder is the
one we should eventually use everywhere. Added Stmt index and Builder
context as ExprEngine globals. To avoid passing them around.

llvm-svn: 142828
2011-10-24 18:26:03 +00:00
Anna Zaks 0bb9d1b917 [analyzer] Use a temporary builder in CheckerContext.
First step toward removing the global Stmt builder. Added several transitional methods (like takeNodes/addNodes).
+ Stop early if the set of exploded nodes for the next iteration is empty.

llvm-svn: 142827
2011-10-24 18:25:58 +00:00
Anna Zaks 7fec527d16 [analyzer] Pass external Dst set to NodeBuilder
This moves the responsibility for storing the output node set from the
builder to the clients. The builder is just responsible for transforming
an input set into the output set: {SrcSet/SrcNode} -> {Frontier}.

llvm-svn: 142826
2011-10-24 18:25:53 +00:00
Ted Kremenek 81ce1c8a99 Rename AnalysisContext to AnalysisDeclContext. Not only is this name more accurate, but it frees up the name AnalysisContext for other uses.
llvm-svn: 142782
2011-10-24 01:32:45 +00:00
Ted Kremenek 142adc492b [analyzer] Remove LocationContext creation methods from AnalysisManager, and change clients to use AnalysisContext instead.
WIP to remove/reduce ExprEngine's usage of AnalysisManager.

llvm-svn: 142739
2011-10-23 02:31:52 +00:00
Anna Zaks d009bfac0c [analyzer] Move predecessor into the NodeBuilder context.
llvm-svn: 142454
2011-10-18 23:06:48 +00:00
Anna Zaks a99b41f37f [analyzer] Make NodeBuilder and Pred node loosely coupled
NodeBuilder should not assume it's dealing with a single predecessor. Remove predecessor getters. Modify the BranchNodeBuilder to not be responsible for doing auto-transitions (which depend on a predecessor).

llvm-svn: 142453
2011-10-18 23:06:44 +00:00
Anna Zaks e83ddcc4ec [analyzer] Remove dead code.
ExprEngineBuilders is not used.

llvm-svn: 142450
2011-10-18 23:06:29 +00:00
Anna Zaks 6d285c58ec [analyzer] Modularize builder use in processBranch.
Take advantage of the new builders for branch processing. As part of this change pass generic NodeBuilder (instead of BranchNodeBuilder) to the BranchCondition callback and remove the unused methods form BranchBuilder.

llvm-svn: 142448
2011-10-18 23:06:21 +00:00
Anna Zaks eebbbc7253 [analyzer] Pull Pred out of NodeBuilderContext.
Each builder will have a different one, so it doesn't make sense to keep it in the context.

llvm-svn: 142447
2011-10-18 23:06:16 +00:00
Anna Zaks ce5e97efdd [analyzer] NodeBuilder Refactoring: Subclass BranchNodeBuilder from NodeBuilder.
llvm-svn: 142444
2011-10-18 23:06:04 +00:00
Richard Smith faa32a9b83 Refactor static analyzer to use simpler interface to constant expression evaluation.
llvm-svn: 141983
2011-10-14 20:22:00 +00:00
Eli Friedman df14b3a837 Initial implementation of __atomic_* (everything except __atomic_is_lock_free).
llvm-svn: 141632
2011-10-11 02:20:01 +00:00
Ted Kremenek 8f34b6999c [analyzer] Teach the static analyzer about CXXForRangeStmt. Patch by Jim Goodnow II!
llvm-svn: 141587
2011-10-10 22:36:31 +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
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
David Blaikie aa347f9392 Removing a bunch of dead returns/breaks after llvm_unreachables.
llvm-svn: 140407
2011-09-23 20:26:49 +00:00
David Blaikie 83d382b1ca Switch assert(0/false) llvm_unreachable.
llvm-svn: 140367
2011-09-23 05:06:16 +00:00
Jordy Rose 087611ed81 [analyzer] Remove TransferFuncs.h, then deal with the fallout.
And with that, TransferFuncs is gone!

llvm-svn: 139003
2011-09-02 08:02:59 +00:00
Jordy Rose a87a2775fa [analyzer] Fix member initialization order. No functionality change.
llvm-svn: 138999
2011-09-02 06:21:26 +00:00
Jordy Rose c49ec53e29 [analyzer] Move the knowledge of whether or not GC is enabled for the current analysis from CFRefCount to ExprEngine.
Remove TransferFuncs from ExprEngine and AnalysisConsumer.

Demote RetainReleaseChecker to a regular checker, and give it the name osx.cocoa.RetainCount (class name change coming shortly). Update tests accordingly.

llvm-svn: 138998
2011-09-02 05:55:19 +00:00
Jordy Rose 58a20d31b7 [analyzer] Introduce a new callback for checkers, printState, to be used for debug-printing the contents of a ProgramState.
Unlike the other callbacks, this one is a simple virtual method, since it is only to be used for debugging.

This new callback replaces the old ProgramState::Printer interface, and allows us to move the printing of refcount bindings from CFRefCount to RetainReleaseChecker.

llvm-svn: 138728
2011-08-28 19:11:56 +00:00
Jordy Rose e9ff97b850 [analyzer] Remove the ProgramState argument from ExprEngine::evalBind; we were ignoring it anyway. No functionality change.
llvm-svn: 138720
2011-08-28 06:02:28 +00:00
Jordy Rose d26e9e7f7c [analyzer] Eliminate almost all uses of TransferFuncs from ExprEngine.
llvm-svn: 138719
2011-08-28 05:54:23 +00:00
Jordy Rose 1fad663126 [analyzer] Change the check::RegionChanges callback to include the regions explicitly requested for invalidation.
Also, allow CallOrObjCMessage to wrap a CXXConstructExpr as well.

Finally, this allows us to remove the clunky whitelisting system from CFRefCount/RetainReleaseChecker. Slight regression due to CXXNewExprs not yet being handled in post-statement callbacks (PR forthcoming).

llvm-svn: 138716
2011-08-27 22:51:26 +00:00
Ted Kremenek adfb445466 Constify the result of CFGStmt::getStmt().
llvm-svn: 138408
2011-08-23 23:05:04 +00:00
Jordy Rose 7861276f47 [analyzer] Move symbol death leak analysis from CFRefCount to RetainReleaseChecker.
llvm-svn: 138353
2011-08-23 19:01:07 +00:00
Ted Kremenek 60d2ec5765 [analyzer] Handle reads of ObjCPropertyRefExprs implicitly in Environment. No need to bind an explicit value and create a new node.
llvm-svn: 138196
2011-08-20 06:23:25 +00:00
Ted Kremenek a9ce612fa2 Start partitioning ExprEngine.cpp into separate .cpp files that handle different parts
of the analysis (e.g., analysis of C expressions, analysis of Objective-C expressions, and so on).

llvm-svn: 138194
2011-08-20 06:00:03 +00:00
Ted Kremenek e1962328f5 [analyzer] teach ExprEngine about loads from static C++ class fields. Fixes <rdar://problem/9948787>.
llvm-svn: 137760
2011-08-16 21:37:52 +00:00