Commit Graph

96 Commits

Author SHA1 Message Date
Benjamin Kramer b4ef66832d Update APIs that return a pair of iterators to return an iterator_range instead.
Convert uses of those APIs into ranged for loops. NFC.

llvm-svn: 228404
2015-02-06 17:25:10 +00:00
Craig Topper 4501832555 Remove unused member variable.
llvm-svn: 220264
2014-10-21 04:19:18 +00:00
Artyom Skrobov 27720765ed Reverting r214064 and r215650 while investigating a pesky performance regression
llvm-svn: 218296
2014-09-23 08:34:41 +00:00
Artyom Skrobov a208a73390 Use the proper post-order traversal in LiveVariables analysis,
to recover the performance after r214064.

Also sorts out the naming for PostOrderCFGView, ReversePostOrderCFGView,
BackwardDataflowWorklist and ForwardDataflowWorklist, to match the accepted
terminology.

Also unifies BackwardDataflowWorklist and ForwardDataflowWorklist to share
the "worklist for prioritization, post-order traversal for fallback" logic,
and to avoid repetitive sorting.

Also cleans up comments in the affected area.

llvm-svn: 215650
2014-08-14 16:04:47 +00:00
Artyom Skrobov 12ce6d91a1 Factoring DataflowWorklist out of LiveVariables and UninitializedValues analyses
llvm-svn: 214064
2014-07-28 08:47:38 +00:00
Craig Topper 2554294321 [C++11] Use 'nullptr'. Analysis edition.
llvm-svn: 209191
2014-05-20 04:30:07 +00:00
Nuno Lopes fb744589bc remove a bunch of unused private methods
found with a smarter version of -Wunused-member-function that I'm playwing with.
Appologies in advance if I removed someone's WIP code.

 ARCMigrate/TransProperties.cpp                  |    8 -----
 AST/MicrosoftMangle.cpp                         |    1 
 Analysis/AnalysisDeclContext.cpp                |    5 ---
 Analysis/LiveVariables.cpp                      |   14 ----------
 Index/USRGeneration.cpp                         |   10 -------
 Sema/Sema.cpp                                   |   33 +++++++++++++++++++++---
 Sema/SemaChecking.cpp                           |    3 --
 Sema/SemaDecl.cpp                               |   20 ++------------
 StaticAnalyzer/Checkers/GenericTaintChecker.cpp |    1 
 9 files changed, 34 insertions(+), 61 deletions(-)

llvm-svn: 204561
2014-03-23 17:12:37 +00:00
Aaron Ballman 535bbcccb1 [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with iterator_range decls(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203947
2014-03-14 17:01:24 +00:00
Benjamin Kramer 15ae783e14 [C++11] Convert sort predicates into lambdas.
No functionality change.

llvm-svn: 203289
2014-03-07 21:35:40 +00:00
Benjamin Kramer 867ea1d426 [C++11] Replace llvm::tie with std::tie.
llvm-svn: 202639
2014-03-02 13:01:17 +00:00
Anna Zaks cf8d2165ff Revert "[analyzer] Refactor conditional expression evaluating code"
This reverts commit r189090.

The original patch introduced regressions (see the added live-variables.* tests). The patch depends on the correctness of live variable analyses, which are not computed correctly. I've opened PR18159 to track the proper resolution to this problem.

The patch was a stepping block to r189746. This is why part of the patch reverts temporary destructor tests that started crashing. The temporary destructors feature is disabled by default.

llvm-svn: 196593
2013-12-06 18:56:29 +00:00
Robert Wilhelm 25284cc95b Use pop_back_val() instead of both back() and pop_back().
No functionality change intended.

llvm-svn: 189112
2013-08-23 16:11:15 +00:00
Pavel Labath 02b64d46a0 [analyzer] Refactor conditional expression evaluating code
Summary:
Instead of digging through the ExplodedGraph, to figure out which edge brought
us here, I compute the value of conditional expression by looking at the
sub-expression values.

To do this, I needed to change the liveness algorithm a bit -- now, the full
conditional expression also depends on all atomic sub-expressions, not only the
outermost ones.

Reviewers: jordan_rose

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1340

llvm-svn: 189090
2013-08-23 07:19:22 +00:00
David Blaikie 00be69ab5c Remove the CFGElement "Invalid" state.
Use Optional<CFG*> where invalid states were needed previously. In the one case
where that's not possible (beginAutomaticObjDtorsInsert) just use a dummy
CFGAutomaticObjDtor.

Thanks for the help from Jordan Rose & discussion/feedback from Ted Kremenek
and Doug Gregor.

Post commit code review feedback on r175796 by Ted Kremenek.

llvm-svn: 175938
2013-02-23 00:29:34 +00:00
David Blaikie 2a01f5d426 Replace CFGElement llvm::cast support to be well-defined.
See r175462 for another example/more details.

llvm-svn: 175796
2013-02-21 20:58:29 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Benjamin Kramer 444a1304ad Include pruning and general cleanup.
llvm-svn: 169095
2012-12-01 17:12:56 +00:00
Anna Zaks 23665a1bcf [analyzer] Teach live variable analyzes that super uses self pointer.
llvm-svn: 161822
2012-08-14 00:36:20 +00:00
Jordan Rose b3244566f0 [analyzer] Variables with destructors are live until the destructor is run.
Test case in the next commit, which enables destructors under certain
circumstances.

llvm-svn: 160805
2012-07-26 20:04:08 +00:00
Ted Kremenek de21a1c964 Bail out the LiveVariables analysis when the CFG is very large, as
we are encountering some scalability issues with memory usage.   The
appropriate long term fix is to make the analysis more scalable, but
this will at least prevent the analyzer swapping when
analyzing very large functions.

llvm-svn: 159578
2012-07-02 20:21:52 +00:00
Ted Kremenek 299cfb7a02 Enhance AnalysisDeclContext::getReferencedBlockVars() to understand PseudoObjExprs. It turns out
that the information collected by this method is a super set of the captured variables in BlockDecl.

llvm-svn: 147122
2011-12-22 01:30:46 +00:00
Ted Kremenek c177d9faf5 Fix regression in LiveVariables when reasoning about variables captured by blocks.
llvm-svn: 147116
2011-12-22 00:46:32 +00:00
David Blaikie 68e081d606 Unweaken vtables as per http://llvm.org/docs/CodingStandards.html#ll_virtual_anch
llvm-svn: 146959
2011-12-20 02:48:34 +00:00
John McCall 29928fc563 We don't add ExprWithCleanups to the CFG, and getSVal looks
through it, so we should look through it for the live-values
analysis as well.

llvm-svn: 144190
2011-11-09 17:10:36 +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
Ted Kremenek 977e30d1c4 Tweak LookThroughStmt() in LiveVariables to properly look through alternativing ParenExprs and OpaqueValueExprs. Thanks to Anna and Argiris for iterating on this function. My original patch embarssingly didn't even pass the Clang tests.
llvm-svn: 143797
2011-11-05 07:34:28 +00:00
Argyrios Kyrtzidis c843fd2afb LookThroughStmt GM release.
llvm-svn: 143796
2011-11-05 07:09:40 +00:00
Argyrios Kyrtzidis e2cbe86dc4 LookThroughStmt v4.6.3
llvm-svn: 143795
2011-11-05 07:06:54 +00:00
Argyrios Kyrtzidis 6b4fa1b4d6 Simplify LookThroughStmt in LiveVariables.cpp
llvm-svn: 143794
2011-11-05 07:03:54 +00:00
Anna Zaks 04994959a3 Another correction to the LiveVariables commit (r143767, r143780).
Make test/Analysis/misc-ps.c test pass.

llvm-svn: 143790
2011-11-05 05:20:59 +00:00
Argyrios Kyrtzidis 3c89fdae03 Fix infinite loop in LiveVariables due to a misplaced 'break' (it would break out of
switch statement, not the while loop).

llvm-svn: 143780
2011-11-05 04:03:43 +00:00
Ted Kremenek 5717049d8e Teach LiveVariables to look through OpaqueValueExprs for extending Stmt liveness.
llvm-svn: 143767
2011-11-05 00:26: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 5abde7cd5e Pull TopologicallySortedCFG out of LiveVariables into its own analysis: PostOrderCFGView.
llvm-svn: 142713
2011-10-22 02:14:23 +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
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
Ted Kremenek c8f008ac31 Fix another major performance regression in LiveVariables by not canonicalizing the underlying ImmutableSets on every analyzed statement (just at merges). Fixes <rdar://problem/10087538>.
llvm-svn: 140958
2011-10-02 01:45:37 +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
Ted Kremenek 459597a6eb Fix massive LiveVariables regression (due to LiveVariables rewrite) by addressing two performance problems:
- Speed of "merge()", which merged data flow facts.  This was doing a set canonicalization on every insertion, which was super slow.
  To fix this, we use ImmutableSetRef.

- Visit CFGBlocks in reverse postorder.  This is a huge speedup, as on some test cases the algorithm would take many iterations
  to converge.

This contains a bunch of copy-paste from UninitializedValues.cpp and ThreadSafety.cpp.  The idea
was to get something working first, and then refactor the common logic for all three files into
a separate analysis/library entry point.

llvm-svn: 139968
2011-09-16 23:01:39 +00:00
Ted Kremenek adfb445466 Constify the result of CFGStmt::getStmt().
llvm-svn: 138408
2011-08-23 23:05:04 +00:00
Ted Kremenek 5ef32dbf2a Cleanup various declarations of 'Stmt*' to be 'Stmt *', etc. in libAnalyzer and libStaticAnalyzer[*]. It was highly inconsistent, and very ugly to look at.
llvm-svn: 137537
2011-08-12 23:37:29 +00:00
Ted Kremenek 84a1ca5280 [analyzer] Simplify logic for ExprEngine::VisitUnaryExprOrTypeTraitExpr to avoid recursion to subexpression.
This exposed bugs in the live variables analysis, and a latent analyzer bug in the SymbolReaper.

llvm-svn: 137006
2011-08-06 00:30:00 +00:00
Benjamin Kramer 3c05b7c161 Make helper functions static.
llvm-svn: 136679
2011-08-02 04:50:49 +00:00
Ted Kremenek e9fda1e48a [analyzer] Overhaul how the static analyzer expects CFGs by forcing CFGs to be linearized only when used by the static analyzer. This required a rewrite of LiveVariables, and exposed a ton of subtle bugs.
The motivation of this large change is to drastically simplify the logic in ExprEngine going forward.

Some fallout is that the output of some BugReporterVisitors is not as accurate as before; those will
need to be fixed over time.  There is also some possible performance regression as RemoveDeadBindings
will be called frequently; this can also be improved over time.

llvm-svn: 136419
2011-07-28 23:07:59 +00:00
Chris Lattner 0e62c1cc0b remove unneeded llvm:: namespace qualifiers on some core types now that LLVM.h imports
them into the clang namespace.

llvm-svn: 135852
2011-07-23 10:55:15 +00:00
Jordy Rose 1734737d9f [analyzer] PR8962 again. Ban ParenExprs (and friends) from block-level expressions (by calling IgnoreParens before adding expressions to blocks). Undo 132769 (LiveVariables' local IgnoreParens), since it's no longer necessary.
Also, have Environment stop looking through NoOp casts; it didn't match the behavior of LiveVariables. And once that's gone, the whole cast block of that switch is unnecessary.

llvm-svn: 132840
2011-06-10 08:49:37 +00:00
Jordy Rose 891d613289 [analyzer] Ignore parentheses around block-level expressions when computing liveness. Fixes the other half of PR8962.
llvm-svn: 132769
2011-06-09 05:44:04 +00:00
Ted Kremenek 9865d7f0e6 Don't report dead stores on unreachable code paths. Fixes <rdar://problem/8405222>.
llvm-svn: 125415
2011-02-11 23:24:26 +00:00
Tom Care e5aa30c722 Add alternate version of LiveVariables analysis that does not kill liveness at assignments. This 'relaxed' liveness is useful in path sensitive analysis for situations where the resulting extended liveness allows us to find some bugs.
- Added killAtAssign flag to LiveVariables
- Added relaxed LiveVariables to AnalysisContext with an accessor

llvm-svn: 112306
2010-08-27 22:30:10 +00:00
John McCall e302792b61 GCC didn't care for my attempt at API compatibility, so brute-force everything
to the new constants.

llvm-svn: 112047
2010-08-25 11:45:40 +00:00