summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* CFGBuilder: Fix crash when visiting delete expression on dependent typeMartin Bohme2016-12-051-5/+7
| | | | | | | | | | | | | | Summary: CXXDeleteExpr::getDestroyedType() can return a null QualType if the destroyed type is a dependent type. This patch protects against this. Reviewers: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27350 llvm-svn: 288665
* Retire llvm::alignOf in favor of C++11 alignof.Benjamin Kramer2016-10-201-2/+1
| | | | | | No functionality change intended. llvm-svn: 284730
* [StaticAnalyzer] Fix UnreachableCode false positives.Daniel Marjamaki2016-10-031-11/+10
| | | | | | | | When there is 'do { } while (0);' in the code the ExplodedGraph and UnoptimizedCFG did not match. Differential Revision: https://reviews.llvm.org/D24759 llvm-svn: 283095
* [CFG] Fix crash finding destructor of lifetime-extended temporary.Devin Coughlin2016-08-021-1/+11
| | | | | | | | | | | Fix a crash under -Wthread-safety when finding the destructor for a lifetime-extending reference. A patch by Nandor Licker! Differential Revision: https://reviews.llvm.org/D22419 llvm-svn: 277522
* P0305R0: Semantic analysis and code generation for C++17 init-statement for ↵Richard Smith2016-07-141-4/+31
| | | | | | | | | | 'if' and 'switch': if (stmt; condition) { ... } Patch by Anton Bikineev! Some minor formatting and comment tweets by me. llvm-svn: 275350
* CFGBuilder: Fix crash when visiting a range-based for over a dependent typeAlexander Kornienko2016-07-081-0/+2
| | | | | | | | | | | | | | | | | Summary: CFG generation is expected to fail in this case, but it should not crash. Also added a test that reproduces the crash. Reviewers: klimek Subscribers: cfe-commits Patch by Martin Boehme! Differential Revision: http://reviews.llvm.org/D21895 llvm-svn: 274834
* Turn copies into references as suggested by clang-tidy's ↵Benjamin Kramer2016-05-271-1/+1
| | | | | | performance-unnecessary-copy-initialization. llvm-svn: 270994
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-201-3/+6
| | | | | | loops to differ. llvm-svn: 263895
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-291-1/+1
| | | | | | r259192 post commit comment. llvm-svn: 259232
* Use range-based for loop to avoid the need for calculating an array size. NFCCraig Topper2015-11-301-4/+1
| | | | llvm-svn: 254282
* [analyzer] Include block capture copy expressions in the CFG.Devin Coughlin2015-11-251-1/+14
| | | | | | | | | | | This prevents spurious dead store warnings when a C++ lambda is casted to a block. I've also added several tests documenting our still-incomplete support for lambda-to-block casts. rdar://problem/22236293 llvm-svn: 254107
* CFG: Delay creating Dtors for CompoundStmts which end in ReturnStmtMatthias Gehre2015-11-141-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: VisitReturnStmt would create a new block with including Dtors, so the Dtors created in VisitCompoundStmts would be in an unreachable block. Example: struct S { ~S(); }; void f() { S s; return; } void g() { S s; } Before this patch, f has one additional unreachable block containing just the destructor of S. With this patch, both f and g have the same blocks. Reviewers: krememek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D13973 llvm-svn: 253107
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Teach -Wtautological-overlap-compare about enumsGeorge Burgess IV2015-10-011-38/+89
| | | | | | | | | Prior to this patch, -Wtautological-overlap-compare would only warn us if there was a sketchy logical comparison between variables and IntegerLiterals. This patch makes -Wtautological-overlap-compare aware of EnumConstantDecls, so it can apply the same logic to them. llvm-svn: 249053
* [analyzer] Create one state for a range switch case instead of multiple.Devin Coughlin2015-09-221-2/+2
| | | | | | | | | | | | | This fixes PR16833, in which the analyzer was using large amounts of memory for switch statements with large case ranges. rdar://problem/14685772 A patch by Aleksei Sidorin! Differential Revision: http://reviews.llvm.org/D5102 llvm-svn: 248318
* Wdeprecated: Make BumpVectorContext movableDavid Blaikie2015-08-131-9/+7
| | | | | | | | | | | Turns out the one place that relied on the implicit copy ctor was safe because it created an object in a state where the dtor was a no-op, but that's more luck that good management. Sure up the API by defining move construction and using it, which implicitly disallows the unreliable copy operations. llvm-svn: 244968
* Use llvm::reverse to make a bunch of loops use foreach. NFC.Pete Cooper2015-07-301-3/+2
| | | | | | | | | | | | | | | | In llvm commit r243581, a reverse range adapter was added which allows us to change code such as for (auto I = Fields.rbegin(), E = Fields.rend(); I != E; ++I) { in to for (const FieldDecl *I : llvm::reverse(Fields)) This commit changes a few of the places in clang which are eligible to use this new adapter. llvm-svn: 243663
* Analysis: Fix example usage comment in CFG.cpp. NFCJonathan Roelofs2015-07-271-1/+1
| | | | | | Patch by Vedant Kumar! llvm-svn: 243275
* [AST] Remove StmtRange in favor of an iterator_range.Benjamin Kramer2015-07-181-1/+2
| | | | | | | | | StmtRange was just a convenient wrapper for two StmtIterators before we had real range support. This removes some of the implicit conversions StmtRange had leading to slightly more verbose code but also should make more obvious what's going on. No functional change intended. llvm-svn: 242615
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-6/+5
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* Fix "the the" in comments/documentation/etc.Eric Christopher2015-06-191-1/+1
| | | | llvm-svn: 240110
* Append CXXDefaultInitExpr's wrapped expression to the CFG when visiting a ↵Enrico Pertoso2015-06-031-0/+13
| | | | | | | | | | | | | | | | | | | constructor initializer Summary: This patch is part of http://llvm-reviews.chandlerc.com/D2181. In-class initializers are appended to the CFG when CFGBuilder::addInitializer is called. Reviewers: jordan_rose, rsmith Reviewed By: jordan_rose Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D2370 llvm-svn: 238913
* Update -Winvalid-noreturn to handle destructors better.Richard Trieu2015-05-281-3/+2
| | | | | | | | | | When checking if a function is noreturn, consider a codepath to be noreturn if the path destroys a class and the class destructor, base class destructors, or member field destructors are marked noreturn. Differential Revision: http://reviews.llvm.org/D9454 llvm-svn: 238382
* Fix 'CFG graph' typo. NFCJonathan Roelofs2015-05-191-3/+3
| | | | | | Patch by Jon Eyolfson! llvm-svn: 237713
* Use 'override/final' instead of 'virtual' for overridden methodsAlexander Kornienko2015-04-111-2/+1
| | | | | | | | | | | | | | | | | | | | Summary: The patch is generated using clang-tidy misc-use-override check. This command was used: tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py \ -checks='-*,misc-use-override' -header-filter='llvm|clang' -j=32 -fix Reviewers: dblaikie Reviewed By: dblaikie Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D8926 llvm-svn: 234678
* Simplify boolean expressions in clang with clang-tidyDavid Blaikie2015-03-091-2/+2
| | | | | | | | Patch by Richard (legalize at xmission dot com). Differential Revision: http://reviews.llvm.org/D8155 llvm-svn: 231619
* Removing LLVM_EXPLICIT, as MSVC 2012 was the last reason for requiring the ↵Aaron Ballman2015-02-151-1/+1
| | | | | | macro. NFC; Clang edition. llvm-svn: 229336
* unique_ptrify the result of CFG::buildCFG/CFGBuilder::buildCFGDavid Blaikie2014-08-291-7/+6
| | | | llvm-svn: 216755
* clangAnalysis: Avoid member initializers in TempDtorContext to appease msc17.NAKAMURA Takumi2014-08-081-5/+8
| | | | llvm-svn: 215193
* Fix branch reachabiliy annotation for temp dtor branches.Manuel Klimek2014-08-081-21/+29
| | | | | | | | | As we only create temp dtor decision branches when a temp dtor needs to be run (as opposed to for each logical branch in the original expression), we must include the information about all previous logical branches when we annotate the temp dtor decision branch. llvm-svn: 215188
* Mark successors as reachable/unreachable instead of changing the CFG.Manuel Klimek2014-08-071-32/+19
| | | | | | As suggested by Ted, this makes a few warnings less aggressive. llvm-svn: 215128
* Fix CFG for temporary dtors when the branch taken is known.Manuel Klimek2014-08-071-14/+18
| | | | | | | Use the parent context when visiting temporaries when we do not insert a temporary dtor decision branch. llvm-svn: 215120
* Model temporary destructors from logical operators with known values.Manuel Klimek2014-08-071-4/+15
| | | | | | | | If the truth value of a LHS is known, we can build the knowledge whether a temporary destructor is executed or not into the CFG. This is needed by the return type analysis. llvm-svn: 215118
* Only have one path in the CFG for ternaries if the condition is known.Manuel Klimek2014-08-071-2/+11
| | | | | | | The return type analysis requires that the CFG is simplified when the truth values of branches are statically known at analysis time. llvm-svn: 215114
* Re-applying r214962.Manuel Klimek2014-08-071-137/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes to the original patch: - model the CFG for temporary destructors in conditional operators so that the destructors of the true and false branch are always exclusive. This is necessary because we must not have impossible paths for the path based analysis to work. - add multiple regression tests with ternary operators Original description: Fix modelling of non-lifetime-extended temporary destructors in the analyzer. Changes to the CFG: When creating the CFG for temporary destructors, we create a structure that mirrors the branch structure of the conditionally executed temporary constructors in a full expression. The branches we create use a CXXBindTemporaryExpr as terminator which corresponds to the temporary constructor which must have been executed to enter the destruction branch. 2. Changes to the Analyzer: When we visit a CXXBindTemporaryExpr we mark the CXXBindTemporaryExpr as executed in the state; when we reach a branch that contains the corresponding CXXBindTemporaryExpr as terminator, we branch out depending on whether the corresponding CXXBindTemporaryExpr was marked as executed. llvm-svn: 215096
* Revert "Fix modelling of non-lifetime-extended temporary destructors in the ↵Rui Ueyama2014-08-061-146/+139
| | | | | | | | | | | | | | | | | | | | analyzer." This reverts commit r214962 because after the change the following code doesn't compile with -Wreturn-type -Werror. #include <cstdlib> class NoReturn { public: ~NoReturn() __attribute__((noreturn)) { exit(1); } }; int check() { true ? NoReturn() : NoReturn(); } llvm-svn: 214998
* Fix modelling of non-lifetime-extended temporary destructors in the analyzer.Manuel Klimek2014-08-061-139/+146
| | | | | | | | | | | | | | | | | | | 1. Changes to the CFG: When creating the CFG for temporary destructors, we create a structure that mirrors the branch structure of the conditionally executed temporary constructors in a full expression. The branches we create use a CXXBindTemporaryExpr as terminator which corresponds to the temporary constructor which must have been executed to enter the destruction branch. 2. Changes to the Analyzer: When we visit a CXXBindTemporaryExpr we mark the CXXBindTemporaryExpr as executed in the state; when we reach a branch that contains the corresponding CXXBindTemporaryExpr as terminator, we branch out depending on whether the corresponding CXXBindTemporaryExpr was marked as executed. llvm-svn: 214962
* Fix some cases of incorrect handling of lifetime extended temporaries.Manuel Klimek2014-07-301-11/+23
| | | | | | | | MaterializeTemporaryExpr already contains information about the lifetime of the temporary; if the lifetime is not the full statement, we do not want to emit a destructor at the end of the full statement for it. llvm-svn: 214292
* When looking for temporary dtors while building the CFG, do not walk intoRichard Smith2014-07-271-1/+26
| | | | | | | | | | lambda expressions (other than their capture initializers) nor blocks. Do walk into default argument expressions and default initializer expressions. These bugs were causing us to produce broken CFGs whenever a lambda expression was used to initialize a libstdc++ std::function object! llvm-svn: 214050
* Fix a crash in Retain Count checker error reportingAnna Zaks2014-06-131-0/+4
| | | | | | | | | Fixes a crash in Retain Count checker error reporting logic by handing the allocation statement retrieval from a BlockEdge program point. Also added a simple CFG dump routine for debugging. llvm-svn: 210960
* Removing an "if (this == nullptr)" check from two print methods. The conditionRichard Trieu2014-06-091-8/+15
| | | | | | | will never be true in a well-defined context. The checking for null pointers has been moved into the caller logic so it does not rely on undefined behavior. llvm-svn: 210498
* Add a check for tautological bitwise comparisons to -Wtautological-compare.Jordan Rose2014-05-201-8/+35
| | | | | | | | | | | This catches issues like: if ((x & 8) == 4) { ... } if ((x | 4) != 3) { ... } Patch by Anders Rönnholm! llvm-svn: 209221
* [C++11] Use 'nullptr'. Analysis edition.Craig Topper2014-05-201-155/+159
| | | | llvm-svn: 209191
* Fix handling of condition variables in the face of temp dtors.Manuel Klimek2014-05-051-8/+5
| | | | | | | | The assignment needs to be before the destruction of the temporary. This patch calls out to addStmt, which invokes VisitDeclStmt, which has all the correct logic for handling temporaries. llvm-svn: 207985
* Add a new subgroup to -Wtautological-compare, -Wtautological-overlap-compare,Richard Trieu2014-04-051-0/+223
| | | | | | | | | | | | | | which warns on compound conditionals that always evaluate to the same value. For instance, (x > 5 && x < 3) will always be false since no value for x can satisfy both conditions. This patch also changes the CFG to use these tautological values for better branch analysis. The test for -Wunreachable-code shows how this change catches additional dead code. Patch by Anders Rönnholm. llvm-svn: 205665
* [analyzer] Fix a CFG printing bug.Jordan Rose2014-04-011-0/+2
| | | | | | | | | Also, add several destructor-related tests. Most of them don't work yet, but it's good to have them recorded. Patch by Alex McCarthy! llvm-svn: 205326
* Improve -Wunreachable-code to provide a means to indicate code is ↵Ted Kremenek2014-03-291-1/+4
| | | | | | | | | | | | | | | | | | intentionally marked dead via if((0)). Taking a hint from -Wparentheses, use an extra '()' as a sigil that a dead condition is intentionally dead. For example: if ((0)) { dead } When this sigil is found, do not emit a dead code warning. When the analysis sees: if (0) it suggests inserting '()' as a Fix-It. llvm-svn: 205069
* [C++11] Replacing CompoundStmt iterators body_begin() and body_end() with ↵Aaron Ballman2014-03-171-3/+2
| | | | | | iterator_range body(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 204040
* [C++11] Replacing DeclStmt iterators decl_begin() and decl_end() with ↵Aaron Ballman2014-03-141-4/+2
| | | | | | iterator_range decls(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203947
OpenPOWER on IntegriCloud