summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add note why we used a switch.Ted Kremenek2013-02-051-0/+1
| | | | llvm-svn: 174449
* Change subexpressions to be visited in the CFG from left-to-right.Ted Kremenek2013-02-051-19/+56
| | | | | | | | | | | | | | | | | This is a more natural order of evaluation, and it is very important for visualization in the static analyzer. Within Xcode, the arrows will not jump from right to left, which looks very visually jarring. It also provides a more natural location for dataflow-based diagnostics. Along the way, we found a case in the analyzer diagnostics where we needed to indicate that a variable was "captured" by a block. -fsyntax-only timings on sqlite3.c show no visible performance change, although this is just one test case. Fixes <rdar://problem/13016513> llvm-svn: 174447
* Implement C++11 semantics for [[noreturn]] attribute. This required splittingRichard Smith2013-01-171-7/+5
| | | | | | | | it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as affecting the function type, whereas [[noreturn]] does not). llvm-svn: 172691
* CFG.cpp: Fix wrapping logic when printing block preds/succs.Will Dietz2013-01-071-2/+2
| | | | | | | | | First check only wrapped with i==8, second wrapped at i==2,8,18,28,... This fix restores the intended behavior: i==8,18,28,... Found with -fsanitize=integer. llvm-svn: 171718
* Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer2012-12-011-8/+8
| | | | | | | | | pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
* Fix bad CFG construction bug when handling C++ 'try' statements.Ted Kremenek2012-11-131-13/+14
| | | | | | | | | | | | | | | | | This code assigned the last created CFGBlock* to the variable 'Block', which is a scratch variable which is null'ed out after a block is completed. By assigning the last created block to 'Block', we start editing a completed block, inserting CFGStmts that should be in another block. This was the case with 'try'. The test case that showed this had a while loop inside a 'try', and the logic before the while loop was being included as part of the "condition block" for the loop. This showed up as a bogus dead store, but could have lots of implications. Turns out this bug was replicated a few times within CFG.cpp, so I went and fixed up those as well. llvm-svn: 167788
* Fix potential null deference in CFG printer.Ted Kremenek2012-10-121-2/+2
| | | | llvm-svn: 165836
* Remove dead store.Ted Kremenek2012-10-121-1/+1
| | | | llvm-svn: 165835
* [analyzer] Always include destructors in the analysis CFG.Jordan Rose2012-09-051-3/+5
| | | | | | | | | | | | | | | | | | | | | 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
* Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.Ted Kremenek2012-08-241-0/+24
| | | | | | Fixes <rdar://problem/11005770>. llvm-svn: 162545
* [analyzer] Support C++ default arguments if they are literal values.Jordan Rose2012-08-231-0/+8
| | | | | | | | | | | | | | | | | | A CXXDefaultArgExpr wraps an Expr owned by a ParmVarDecl belonging to the called function. In general, ExprEngine and Environment ought to treat this like a ParenExpr or other transparent wrapper expression, with the inside expression evaluated first. However, if we call the same function twice, we'd produce a CFG that contains the same wrapped expression twice, and we're not set up to handle that. I've added a FIXME to the CFG builder to come back to that, but meanwhile we can at least handle expressions that don't need to be explicitly evaluated: literals. This probably handles many common uses of default parameters: true/false, null, etc. Part of PR13385 / <rdar://problem/12156507> llvm-svn: 162453
* Rename 'currentX' to 'currX' throughout analyzer and libAnalysis.Ted Kremenek2012-08-221-5/+5
| | | | | | | | | Also rename 'getCurrentBlockCounter()' to 'blockCount()'. This ripples a bunch of code simplifications; mostly aesthetic, but makes the code a bit tighter. llvm-svn: 162349
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* When a && or || appears as the condition of a ?:, perform appropriateRichard Smith2012-07-241-10/+13
| | | | | | | | | short-circuiting when building the CFG. Also be sure to skip parens before checking for the && / || special cases. Finally, fix some crashes in CFG printing in the presence of calls to destructors for array of array of class type. llvm-svn: 160691
* Add a reverse iterator to DeclStmt, and use it when building a CFG.Jordan Rose2012-07-201-5/+4
| | | | | | | The CFG creates dummy DeclStmts with one Decl per statement, and it has to do so from last to first in order to build the graph correctly. llvm-svn: 160560
* Teach CFG construction about destructors resulting from references to array ↵Ted Kremenek2012-07-181-5/+4
| | | | | | types. Fixes crash in <rdar://problem/11671507>. llvm-svn: 160424
* Refine CFG so that '&&' and '||' don't lead to extra confluence points when ↵Ted Kremenek2012-07-141-150/+232
| | | | | | | | | | | | | | | | | | used in a branch, but instead push the terminator for the branch down into the basic blocks of the subexpressions of '&&' and '||' respectively. This eliminates some artifical control-flow from the CFG and results in a more compact CFG. Note that this patch only alters the branches 'while', 'if' and 'for'. This was complex enough for one patch. The remaining branches (e.g., do...while) can be handled in a separate patch, but they weren't immediately tackled because they were less important. It is possible that this patch introduces some subtle bugs, particularly w.r.t. to destructor placement. I've tried to audit these changes, but it is also known that the destructor logic needs some refinement in the area of '||' and '&&' regardless (i.e., their are known bugs). llvm-svn: 160218
* Hoist CFG builder logic for '&&' and '||' into helper method. No ↵Ted Kremenek2012-07-141-40/+45
| | | | | | funcationlity change. llvm-svn: 160217
* Remove unused method declaration.Ted Kremenek2012-07-141-1/+0
| | | | llvm-svn: 160216
* Sort prototypes. No functionality change.Ted Kremenek2012-07-141-19/+18
| | | | llvm-svn: 160215
* Drop the ASTContext.h include from Stmt.h and fix up transitive users.Benjamin Kramer2012-07-041-0/+1
| | | | | | | | | | | | | | This required moving the ctors for IntegerLiteral and FloatingLiteral out of line which shouldn't change anything as they are usually called through Create methods that are already out of line. ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector and make it independent from ASTContext.h Pass the StorageAllocator directly to AccessedEntity so it doesn't need to have a definition of ASTContext around. llvm-svn: 159718
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-1/+1
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Zap the /Za compiler switch from MSVC projects, the option is considered ↵Francois Pichet2012-06-061-2/+2
| | | | | | | | harmful even by Microsoft people and clang won't build using the MSVC 2012 RC if not removed. Only 1 minor code change was necessary: can't use cdecl as variable name anymore. llvm-svn: 158063
* Add -Wimplicit-fallthrough warning flag, which warns on fallthrough betweenRichard Smith2012-05-031-3/+0
| | | | | | | | | | | | cases in switch statements. Also add a [[clang::fallthrough]] attribute, which can be used to suppress the warning in the case of intentional fallthrough. Patch by Alexander Kornienko! The handling of C++11 attribute namespaces in this patch is temporary, and will be replaced with a cleaner mechanism in a subsequent patch. llvm-svn: 156086
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-1/+1
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.Richard Smith2012-04-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a new flavor of exception specification, EST_Uninstantiated. A function type with this exception specification carries a pointer to a FunctionDecl, and the exception specification for that FunctionDecl is instantiated (if needed) and used in the place of the function type's exception specification. When a function template declaration with a non-trivial exception specification is instantiated, the specialization's exception specification is set to this new 'uninstantiated' kind rather than being instantiated immediately. Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs on-demand. Also, any odr-use of a function triggers the instantiation of its exception specification (the exception specification could be needed by IRGen). In passing, fix two places where a DeclRefExpr was created but the corresponding function was not actually marked odr-used. We used to get away with this, but don't any more. Also fix a bug where instantiating an exception specification which refers to function parameters resulted in a crash. We still have the same bug in default arguments, which I'll be looking into next. This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to parse (and, in very limited testing, support) all of libstdc++4.7's standard headers. llvm-svn: 154886
* Add an AttributedStmt type to represent a statement with C++11 attributesRichard Smith2012-04-141-1/+5
| | | | | | | | | attached. Since we do not support any attributes which appertain to a statement (yet), testing of this is necessarily quite minimal. Patch by Alexander Kornienko! llvm-svn: 154723
* Include lambda capture init expressions in CFG.Ted Kremenek2012-04-121-1/+17
| | | | llvm-svn: 154611
* Fix CFGBuilder to not include the body of a LambdaExpr in the CFG of the ↵Ted Kremenek2012-04-121-3/+5
| | | | | | enclosing function. llvm-svn: 154607
* clang/lib/Analysis/CFG.cpp: Get rid of early insertion of placeholder to the ↵NAKAMURA Takumi2012-03-251-7/+4
| | | | | | map. llvm-svn: 153407
* clang/lib/Analysis/CFG.cpp: Fix memory leak since r153297.NAKAMURA Takumi2012-03-251-2/+5
| | | | | | evaluateAsBooleanConditionNoCache(S) might update the map and invalidate the iterator. llvm-svn: 153406
* [CFG] Cache boolean evaluations of expressions to avoid multiple re-evaluationsArgyrios Kyrtzidis2012-03-231-7/+66
| | | | | | | | | | during construction of branches for chained logical operators. This makes -fsyntax-only for test/Sema/many-logical-ops.c about 32x times faster. With measuring SemaExpr.cpp I see differences below the noise level. llvm-svn: 153297
* Fix broken CFG when an initializer is a statement expression that starts ↵Ted Kremenek2012-03-221-5/+15
| | | | | | with a while loop (PR 12325). llvm-svn: 153242
* Fix crash when querying the CFG reported when using the thread safety analysisTed Kremenek2012-03-191-1/+1
| | | | | | | on code using multi-dimensional arrays. Fix by DeLesley Hutchins, and reported in PR 12271. llvm-svn: 153067
* 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
* [analyzer] fix regression in analyzer of NOT actually aborting on Stmts it ↵Ted Kremenek2012-03-101-1/+10
| | | | | | | | | | | doesn't understand. We registered as aborted, but didn't treat such cases as sinks in the ExplodedGraph. Along the way, add basic support for CXXCatchStmt, expanding the set of code we actually analyze (hopefully correctly). Fixes: <rdar://problem/10892489> llvm-svn: 152468
* AST representation for user-defined literals, plus just enough of semanticRichard Smith2012-03-071-0/+1
| | | | | | | | | | | | | | | | | | | | | analysis to make the AST representation testable. They are represented by a new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic properties, including full CodeGen support, are achieved for free by this representation. UserDefinedLiterals can never be dependent, so no custom instantiation behavior is required. They are mangled as if they were direct calls to the underlying literal operator. This matches g++'s apparent behavior (but not its actual mangling, which is broken for literal-operator-ids). User-defined *string* literals are now fully-operational, but the semantic analysis is quite hacky and needs more work. No other forms of user-defined literal are created yet, but the AST support for them is present. This patch committed after midnight because we had already hit the quota for new kinds of literal yesterday. llvm-svn: 152211
* Fix horrific CFG bug where '@autoreleasepool' would be put in a dangling ↵Ted Kremenek2012-03-061-0/+10
| | | | | | block in the CFG. llvm-svn: 152163
* 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
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | llvm-svn: 149798
* [CFG] Removed unused local variable.Erik Verbruggen2012-01-311-2/+0
| | | | llvm-svn: 149385
* Revert various template unreachability code I committed accidentally.David Blaikie2012-01-241-8/+9
| | | | | | r148774, r148775, r148776, r148777 llvm-svn: 148780
* More fixes/tests.David Blaikie2012-01-241-2/+2
| | | | llvm-svn: 148777
* Support undefined dependent bases.David Blaikie2012-01-241-7/+6
| | | | llvm-svn: 148775
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-1/+0
| | | | llvm-svn: 148577
* Add elidable CXXConstructExpr as block-level expr. It converts an lvalue to ↵Zhongxing Xu2012-01-111-2/+1
| | | | | | a rvalue, which is a useful step during AST evaluation. llvm-svn: 147918
* Enable the user to control whether CXXConstructExpr will be added as a Zhongxing Xu2011-12-281-1/+1
| | | | | | | | | | block-level expr. Currently CXXConstructExpr is always added as a block-level expr. This caused two problems for the analyzer (and potentially for the CFG-based codegen). 1. We have no way to know whether a ctor call is base or complete. 2. We have no way to know the destination object being contructed. llvm-svn: 147306
* Colorize and condense CFG pretty-printing.Ted Kremenek2011-12-221-47/+90
| | | | llvm-svn: 147203
* Improve CFG pretty-printing for CXXConstructExprs.Ted Kremenek2011-12-211-0/+3
| | | | llvm-svn: 147068
OpenPOWER on IntegriCloud