summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Improve CFG pretty-printing of CastExprs.Ted Kremenek2011-12-211-1/+8
| | | | llvm-svn: 147066
* [analyzer] Rely on LLVM Dominators in Clang dominator computation.Anna Zaks2011-12-051-1/+1
| | | | | | | | (Previously, Clang used it's implementation of dominators.) The patch is contributed by Guoping Long! llvm-svn: 145858
* Teach the CFG builder how to properly destroy temporaries whoDouglas Gregor2011-11-151-8/+57
| | | | | | | | lifetimes have been extended via reference binding. The type of the reference and the type of the temporary are not necessarily the same, which could cause a crash. Fixes <rdar://problem/10398199>. llvm-svn: 144646
* Change the AST representation of operations on Objective-CJohn McCall2011-11-061-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Per discussion with John McCall, don't add OpaqueValueExprs to the CFG.Ted Kremenek2011-11-051-1/+4
| | | | llvm-svn: 143766
* Rename Expr::Evaluate to Expr::EvaluateAsRValue to make it clear that it willRichard Smith2011-10-291-1/+1
| | | | | | | | implicitly perform an lvalue-to-rvalue conversion if used on an lvalue expression. Also improve the documentation of Expr::Evaluate* to indicate which of them will accept expressions with side-effects. llvm-svn: 143263
* Refactor static analyzer to use simpler interface to constant expression ↵Richard Smith2011-10-141-21/+8
| | | | | | evaluation. llvm-svn: 141983
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-2/+2
| | | | llvm-svn: 140367
* Add a bit to the CFGBlock to track when it contains a no-returnChandler Carruth2011-09-131-0/+1
| | | | | | | CFGElement. This will allow greatly simplifying the logic in -Wreturn-type. llvm-svn: 139593
* Consolidate the logic for building a no-return CFG block into a singleChandler Carruth2011-09-131-23/+21
| | | | | | | location with a single comment rather than scattering it in three places. llvm-svn: 139592
* Enhance the CFG construction to detect no-return destructors forChandler Carruth2011-09-131-28/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | temporary objects and local variables. When detected, these split the block, marking the new one as having only the exit block as a successor. This prevents a large number of false positives in warnings sensitive to no-return constructs such as -Wreturn-type, and fixes the remainder of PR10063 along with several variations of this bug that had not been reported. The test cases are extended across the board to cover these patterns. This also checks in a stress test for these types of CFGs. The stress test declares some 32k variables, a mixture of no-return and normal destructors. Previously, this resulted in roughly 2500 CFG blocks, but didn't model any of the no-return destructors. With this patch, it results in over 33k blocks, many of them now unreachable. The nice thing about how the analyzer is set up? This causes *no* regression in performance of building the CFG. It actually in some cases makes it faster, as best I can benchmark. The analysis for -Wreturn-type (and any other that cares about no-return code paths) is technically slower now as it has to look at many more candidate blocks, but it computes the correct answer. I have more test cases to follow, I think they all work now. Also I have further work that should dramatically simplify analyses in the presence of no-return. llvm-svn: 139586
* Extend the Stmt AST to make it easier to look through label, default,Chandler Carruth2011-09-101-6/+2
| | | | | | | | | | | and case statements. Use this to make the logic in the CFG builder more robust at finding the actual statements within a compound statement, even when there are many layers of labels obscuring it. Also extend the test cases for a large chunk of PR10063. Still more work to do here though. llvm-svn: 139437
* CFG: record set of C++ 'try' dispatch blocks, which could be of interest to ↵Ted Kremenek2011-08-231-2/+2
| | | | | | various analyses (e.g., reachability). llvm-svn: 138409
* Constify the result of CFGStmt::getStmt().Ted Kremenek2011-08-231-12/+12
| | | | llvm-svn: 138408
* Fix regression in -Wuninitialized involving VLAs. It turns out that we were ↵Ted Kremenek2011-08-231-9/+0
| | | | | | | | | | | modeling sizeof(VLAs) incorrectly in the CFG, and also the static analyzer. This patch regresses the analyzer a bit, but that needs to be followed up with a better solution. Fixes <rdar://problem/10008112>. llvm-svn: 138372
* Fix else style. No functionality change intended.Chad Rosier2011-08-171-2/+1
| | | | llvm-svn: 137896
* Fix a handful of dead stores found by Clang's static analyzer. There's a ↵Ted Kremenek2011-08-171-2/+2
| | | | | | bunch of others I haven't touched. llvm-svn: 137867
* Cleanup various declarations of 'Stmt*' to be 'Stmt *', etc. in libAnalyzer ↵Ted Kremenek2011-08-121-160/+160
| | | | | | and libStaticAnalyzer[*]. It was highly inconsistent, and very ugly to look at. llvm-svn: 137537
* Revert "Fix crash in CFGBuilder involving implicit destructor calls and ↵Ted Kremenek2011-08-121-8/+6
| | | | | | gotos jumping after an object was declared. Fixes PR 10620." llvm-svn: 137459
* Fix crash in CFGBuilder involving implicit destructor calls and gotos ↵Ted Kremenek2011-08-121-6/+8
| | | | | | jumping after an object was declared. Fixes PR 10620. llvm-svn: 137426
OpenPOWER on IntegriCloud