summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* [analyzer] Simplify logic for ExprEngine::VisitUnaryExprOrTypeTraitExpr to ↵Ted Kremenek2011-08-061-0/+9
| | | | | | | | avoid recursion to subexpression. This exposed bugs in the live variables analysis, and a latent analyzer bug in the SymbolReaper. llvm-svn: 137006
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-11/+11
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Add hooks into the CFG builder to force that specific expressions are always ↵Ted Kremenek2011-07-191-5/+7
| | | | | | CFGElements. llvm-svn: 135479
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* [analyzer] PR8962 again. Ban ParenExprs (and friends) from block-level ↵Jordy Rose2011-06-101-10/+15
| | | | | | | | 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
* Add explicit CFG support for ignoring static_asserts.Ted Kremenek2011-05-241-1/+9
| | | | llvm-svn: 132001
* Refactoring of constant expression evaluatorPeter Collingbourne2011-05-131-1/+1
| | | | | | | | | This introduces a generic base class for the expression evaluator classes, which handles a few common expression types which were previously handled separately in each class. Also, the expression evaluator now uses ConstStmtVisitor. llvm-svn: 131281
* Teach CFG building how to deal with CXXMemberCallExprs and BoundMemberTy,John McCall2011-05-111-15/+12
| | | | | | | then teach -Wreturn-type to handle the same. Net effect: we now correctly handle noreturn attributes on member calls in the CFG. llvm-svn: 131178
* Elide __label__ declarations from the CFG. This resolves a crash in ↵Ted Kremenek2011-05-101-0/+5
| | | | | | CFGRecStmtDeclVisitor (crash in static analyzer). llvm-svn: 131141
* Remove unused method CFGBlock::hasBinaryBranchTerminator().Ted Kremenek2011-04-271-26/+0
| | | | llvm-svn: 130336
* Fix PR9741. The implicit declarations created for range-based for loops ↵Richard Smith2011-04-181-2/+2
| | | | | | weren't being added to the DeclContext (nor were they being marked as implicit). Also, the declarations were being emitted in the wrong order when building the CFG. llvm-svn: 129700
* fix a bunch of comment typos found by codespell. Patch byChris Lattner2011-04-151-2/+2
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129559
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+120
| | | | | | draft standard (N3291). llvm-svn: 129541
* Return the correct lastly populated block from ↵Ted Kremenek2011-04-141-2/+4
| | | | | | CFGBuilder::VisitUnaryExprOrTypeTraitExpr(). llvm-svn: 129499
* Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with ↵Ted Kremenek2011-04-041-6/+6
| | | | | | | | | | | | | | numerous CFG and UninitializedValues analysis changes: 1) Change the CFG to include the DeclStmt for conditional variables, instead of using the condition itself as a faux DeclStmt. 2) Update ExprEngine (the static analyzer) to understand (1), so not to regress. 3) Update UninitializedValues.cpp to initialize all tracked variables to Uninitialized at the start of the function/method. 4) Only use the SelfReferenceChecker (SemaDecl.cpp) on global variables, leaving the dataflow analysis to handle other cases. The combination of (1) and (3) allows the dataflow-based -Wuninitialized to find self-init problems when the initializer contained control-flow. llvm-svn: 128858
* -Wuninitialized: don't warn about uninitialized variables in unreachable code.Ted Kremenek2011-04-041-2/+2
| | | | llvm-svn: 128840
* Fix CFG-construction bug when run from ↵Ted Kremenek2011-03-231-9/+23
| | | | | | | | AnalysisBasedWarnings::IssueWarnings() where block-level expressions that need to be recorded in the Stmt*->CFGBlock* map were not always done so. Fixes <rdar://problem/9171946>. llvm-svn: 128170
* Teach CFGBuilder that the 'default' branch of a switch statement is dead if ↵Ted Kremenek2011-03-161-2/+4
| | | | | | all enum values in a switch conditioned are handled. llvm-svn: 127727
* Instead of storing an ASTContext* in FunctionProtoTypes with computed ↵Sebastian Redl2011-03-131-3/+3
| | | | | | noexcept specifiers, unique FunctionProtoTypes with a ContextualFoldingSet, as suggested by John McCall. llvm-svn: 127568
* Fix CFG assertion failure reported in PR 9467. This was due to recent ↵Ted Kremenek2011-03-131-8/+11
| | | | | | changes in optimizing CFGs for switch statements. llvm-svn: 127563
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-121-1/+1
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* Add support for the OpenCL vec_step operator, by generalising andPeter Collingbourne2011-03-111-5/+7
| | | | | | | extending the existing support for sizeof and alignof. Original patch by Guy Benyei. llvm-svn: 127475
* When doing reachability analysis for warnings issued under ↵Ted Kremenek2011-03-101-4/+32
| | | | | | | | | DiagRuntimeBehavior, don't construct a ParentMap or CFGStmtMap. Instead, create a small set of Stmt* -> CFGBlock* mappings during CFG construction for only the statements we care about relating to the diagnostics we want to check for reachability. llvm-svn: 127396
* Require AddStmtChoice::alwaysAdd() to take a CFGBuilder& and Stmt*. Prep ↵Ted Kremenek2011-03-101-15/+22
| | | | | | for functionality changes. llvm-svn: 127387
* Remove unused 'AddStmtChoice' argument to CFGBuilder::appendStmt().Ted Kremenek2011-03-101-25/+24
| | | | llvm-svn: 127386
* Rework interaction between AnalysisContext and CFG::BuildOptions to keep a ↵Ted Kremenek2011-03-101-17/+13
| | | | | | | | | | | | BuildOptions object around instead of keeping a copy of the flags. Moreover, change AnalysisContext to use an OwningPtr for created analysis objects instead of directly managing them. Finally, add a 'forcedBlkExprs' entry to CFG::BuildOptions that will be used by the CFGBuilder to force specific expressions to be block-level expressions. llvm-svn: 127385
* Fix null dereference in CFGBlock::FilterEdge that was reported in PR 9412.Ted Kremenek2011-03-071-5/+5
| | | | llvm-svn: 127176
* Correctly handle nested switch statements in CFGBuilder when on switch ↵Ted Kremenek2011-03-041-11/+12
| | | | | | statement has a condition that evaluates to a constant. llvm-svn: 126977
* Teach CFGImplicitDtor::getDestructorDecl() about arrays of objects with ↵Ted Kremenek2011-03-031-3/+7
| | | | | | destructors. llvm-svn: 126910
* Teach CFGImplicitDtor::getDestructorDecl() about reference types.Ted Kremenek2011-03-031-2/+3
| | | | llvm-svn: 126909
* Let's go with John and Ted's preferred fix.Matt Beaumont-Gay2011-03-031-1/+2
| | | | llvm-svn: 126907
* Keep GCC from complaining about falling off the end of the function.Matt Beaumont-Gay2011-03-021-0/+1
| | | | llvm-svn: 126897
* Introduce CFGImplicitDtor::isNoReturn() to query whether a destructor ↵Ted Kremenek2011-03-021-1/+34
| | | | | | actually returns. Use this for -Wreturn-type to prune false positives reported in PR 6884. llvm-svn: 126875
* Teach CFGBuilder to prune trivially unreachable case statements.Ted Kremenek2011-03-011-38/+106
| | | | llvm-svn: 126797
* In preparation for fixing PR 6884, rework CFGElement to have getAs<> return ↵Ted Kremenek2011-03-011-46/+70
| | | | | | | | | pointers instead of fresh CFGElements. - Also, consoldiate getDtorKind() and getKind() into one "kind". - Add empty getDestructorDecl() method to CFGImplicitDtor. llvm-svn: 126738
* Get rid of the areExceptionsEnabled() getter from LangOptions.Anders Carlsson2011-02-281-1/+1
| | | | llvm-svn: 126598
* Fix tiny error in CFG construction for BinaryConditionalOperators, making ↵Ted Kremenek2011-02-241-12/+14
| | | | | | | | | sure the branch always has two successors. Also teach Environment::getSVal() about OpaqueValueExprs. This fixes a crash reported in PR9287, and also fixes a false positive involving the value of such ternary expressions not properly getting propagated. llvm-svn: 126362
* Teach CFGBuilder about null pointer constants in conditionals, and how they ↵Ted Kremenek2011-02-231-3/+11
| | | | | | can be used to prune branches. Fixes false null pointer dereference warning in PR 8183. llvm-svn: 126305
* Fix a CFGBuilder bug exposed on convoluted control-flow in the Linux kernel.Ted Kremenek2011-02-211-5/+8
| | | | llvm-svn: 126149
OpenPOWER on IntegriCloud