summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/AnalysisDeclContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Include analysis stack in crash traces.Jordan Rose2013-07-191-6/+10
| | | | | | | | | | | | | Sample output: 0. Program arguments: ... 1. <eof> parser at end of file 2. While analyzing stack: #0 void inlined() #1 void test() 3. crash-trace.c:6:3: Error evaluating statement llvm-svn: 186639
* [analyzer; new edges] Simplify edges in a C++11 for-range loop.Jordan Rose2013-06-061-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously our edges were completely broken here; now, the final result is a very simple set of edges in most cases: one up to the "for" keyword for context, and one into the body of the loop. This matches the behavior for ObjC for-in loops. In the AST, however, CXXForRangeStmts are handled very differently from ObjCForCollectionStmts. Since they are specified in terms of equivalent statements in the C++ standard, we actually have implicit AST nodes for all of the semantic statements. This makes evaluation very easy, but diagnostic locations a bit trickier. Fortunately, the problem can be generally defined away by marking all of the implicit statements as part of the top-level for-range statement. One of the implicit statements in a for-range statement is the declaration of implicit iterators __begin and __end. The CFG synthesizes two separate DeclStmts to match each of these decls, but until now these synthetic DeclStmts weren't in the function's ParentMap. Now, the CFG keeps track of its synthetic statements, and the AnalysisDeclContext will make sure to add them to the ParentMap. <rdar://problem/14038483> llvm-svn: 183449
* Revert "[analyzer; alternate edges] improve support for edges with ↵Jordan Rose2013-05-181-22/+8
| | | | | | | | | | | | | PseudoObjectExprs." Ted and I spent a long time discussing this today and found out that neither the existing code nor the new code was doing what either of us thought it was, which is never good. The good news is we found a much simpler way to fix the motivating test case (an ObjCSubscriptExpr). This reverts r182083, but pieces of it will come back in subsequent commits. llvm-svn: 182185
* [analyzer; alternate edges] improve support for edges with PseudoObjectExprs.Ted Kremenek2013-05-171-8/+22
| | | | | | | | | | | | | | | | | | This optimizes some spurious edges resulting from PseudoObjectExprs. This required far more changes than I anticipated. The current ParentMap does not record any hierarchy information between a PseudoObjectExpr and its *semantic* expressions that may be wrapped in OpaqueValueExprs, which are the expressions actually laid out in the CFG. This means the arrow pruning logic could not map from an expression to its containing PseudoObjectExprs. To solve this, this patch adds a variant of ParentMap that returns the "semantic" parentage of expressions (essentially as they are viewed by the CFG). This alternate ParentMap is then used by the arrow reducing logic to identify edges into pseudo object expressions, and then eliminate them. llvm-svn: 182083
* [analyzer] Add debug helper LocationContext::dumpStack().Jordan Rose2013-03-301-0/+26
| | | | | | | | | | | Sample output: #0 void construct(pointer __p, llvm::ImutAVLTree<llvm::ImutContainerInfo<clang::ento::BugType *> > *const &__val) #1 void push_back(const value_type &__x) #2 void destroy() #3 void release() #4 void ~ImmutableSet() llvm-svn: 178400
* Add configuration plumbing to enable static initializer branching in the CFG ↵Ted Kremenek2013-03-291-1/+3
| | | | | | | | | for the analyzer. This setting still isn't enabled yet in the analyzer. This is just prep work. llvm-svn: 178317
* clang/Analysis: Fix r174245, a valgrind error in ↵NAKAMURA Takumi2013-02-041-0/+1
| | | | | | AnalysisDeclContext::getBody(bool &IsAutosynthesized), to initialize IsAutosynthesized explicitly. llvm-svn: 174303
* [analyzer] Always inline functions with bodies generated by BodyFarm.Anna Zaks2013-02-021-2/+15
| | | | | | | | Inlining these functions is essential for correctness. We often have cases where we do not inline calls. For example, the shallow mode and when reanalyzing previously inlined ObjC methods as top level. llvm-svn: 174245
* Use the BlockDecl captures list to infer the direct captures for a ↵Ted Kremenek2012-12-061-4/+7
| | | | | | | | | BlockDataRegion. Fixes <rdar://problem/12415065>. We still need to do a recursive walk to determine all static/global variables referenced by a block, which is needed for region invalidation. llvm-svn: 169481
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-5/+4
| | | | | | | | | | | | | 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
* [analyzer] add LocationContext::inTopFrame() helper.Anna Zaks2012-11-031-0/+4
| | | | llvm-svn: 167351
* Add clarifying comment.Ted Kremenek2012-09-241-0/+2
| | | | llvm-svn: 164557
* Implement faux-body-synthesis of well-known functions in the static analyzer ↵Ted Kremenek2012-09-211-6/+25
| | | | | | | | | | | | | | | | | | | | | | | when their implementations are unavailable. Start by simulating dispatch_sync(). This change is largely a bunch of plumbing around something very simple. We use AnalysisDeclContext to conjure up a fake function body (using the current ASTContext) when one does not exist. This is controlled under the analyzer-config option "faux-bodies", which is off by default. The plumbing in this patch is largely to pass the necessary machinery around. CallEvent needs the AnalysisDeclContextManager to get the function definition, as one may get conjured up lazily. BugReporter and PathDiagnosticLocation needed to be relaxed to handle invalid locations, as the conjured body has no real source locations. We do some primitive recovery in diagnostic generation to generate some reasonable locations (for arrows and events), but it can be improved. llvm-svn: 164339
* [analyzer] Always include destructors in the analysis CFG.Jordan Rose2012-09-051-2/+4
| | | | | | | | | | | | | | | | | | | | | While destructors will continue to not be inlined (unless the analyzer config option 'c++-inlining' is set to 'destructors'), leaving them out of the CFG is an incomplete model of the behavior of an object, and can cause false positive warnings (like PR13751, now working). Destructors for temporaries are still not on by default, since (a) we haven't actually checked this code to be sure it's fully correct (in particular, we probably need to be very careful with regard to lifetime-extension when a temporary is bound to a reference, C++11 [class.temporary]p5), and (b) ExprEngine doesn't actually do anything when it sees a temporary destructor in the CFG -- not even invalidate the object region. To enable temporary destructors, set the 'cfg-temporary-dtors' analyzer config option to '1'. The old -cfg-add-implicit-dtors cc1 option, which controlled all implicit destructors, has been removed. llvm-svn: 163264
* [analyzer] Don't crash on implicit statements inside initializers.Jordan Rose2012-07-261-1/+9
| | | | | | | | | | | | | | | | | | | Our BugReporter knows how to deal with implicit statements: it looks in the ParentMap until it finds a parent with a valid location. However, since initializers are not in the body of a constructor, their sub-expressions are not in the ParentMap. That was easy enough to fix in AnalysisDeclContext. ...and then even once THAT was fixed, there's still an extra funny case of Objective-C object pointer fields under ARC, which are initialized with a top-level ImplicitValueInitExpr. To catch these cases, PathDiagnosticLocation will now fall back to the start of the current function if it can't find any other valid SourceLocations. This isn't great, but it's miles better than a crash. (All of this is only relevant when constructors and destructors are being inlined, i.e. under -cfg-add-initializers and -cfg-add-implicit-dtors.) llvm-svn: 160810
* Drop the ASTContext.h include from DeclFriend.h and DeclTemplate.h.Benjamin Kramer2012-07-041-0/+1
| | | | llvm-svn: 159723
* static analyzer: add inlining support for directly called blocks.Ted Kremenek2012-06-011-14/+27
| | | | llvm-svn: 157833
* [analyzer] Remove references to idx::TranslationUnit. Index is dead, ↵Jordy Rose2012-04-281-8/+3
| | | | | | cross-TU inlining never panned out. llvm-svn: 155751
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Replace a map of boolean values with a set.Benjamin Kramer2012-03-101-14/+8
| | | | | | No functionality change. llvm-svn: 152494
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-101-11/+7
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. llvm-svn: 152491
* Move llvm/ADT/SaveAndRestore.h -> llvm/Support/SaveAndRestore.h.Argyrios Kyrtzidis2012-03-011-1/+1
| | | | | | Needs llvm update. llvm-svn: 151829
* Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h"Argyrios Kyrtzidis2012-02-271-1/+1
| | | | | | | | to make it more widely available. Depends on llvm commit r151564 llvm-svn: 151566
* Colorize and condense CFG pretty-printing.Ted Kremenek2011-12-221-2/+2
| | | | llvm-svn: 147203
* Enhance AnalysisDeclContext::getReferencedBlockVars() to understand ↵Ted Kremenek2011-12-221-1/+11
| | | | | | | | PseudoObjExprs. It turns out that the information collected by this method is a super set of the captured variables in BlockDecl. llvm-svn: 147122
* [analyzer] teach AnalysisDeclContext::getSelfDecl() about blocks that ↵Ted Kremenek2011-11-141-0/+9
| | | | | | capture the 'self' variable of the enclosing ObjC method decl. Fixes <rdar://problem/10380300>. llvm-svn: 144556
* Actually rename the file AnalysisContext.cpp -> AnalysisDeclContext.cppChandler Carruth2011-10-241-0/+454
to match the CMakeLists.txt change in r142782; this should fix the CMake build. llvm-svn: 142784
OpenPOWER on IntegriCloud