summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/dead-stores.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Add a checker option to detect nested dead storesKristof Umann2019-09-031-29/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables the users to specify an optional flag which would warn for more dead stores. Previously it ignored if the dead store happened e.g. in an if condition. if ((X = generate())) { // dead store to X } This patch introduces the `WarnForDeadNestedAssignments` option to the checker, which is `false` by default - so this change would not affect any previous users. I have updated the code, tests and the docs as well. If I missed something, tell me. I also ran the analysis on Clang which generated 14 more reports compared to the unmodified version. All of them seemed reasonable for me. Related previous patches: rGf224820b45c6847b91071da8d7ade59f373b96f3 Reviewers: NoQ, krememek, Szelethus, baloghadamsoftware Reviewed By: Szelethus Patch by Balázs Benics! Differential Revision: https://reviews.llvm.org/D66733 llvm-svn: 370767
* Reland 4: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-031-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296895
* Revert "Reland 3: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | multiple constraint managers" This reverts commit ea36f1406e1f36bf456c3f3929839b024128e468. llvm-svn: 296841
* Reland 3: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296837
* Revert "Reland 2: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | multiple constraint managers" This reverts commit f93343c099fff646a2314cc7f4925833708298b1. llvm-svn: 296836
* Reland 2: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-021-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296835
* Revert "Reland: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-02-281-2/+2
| | | | | | | | multiple constraint managers" This reverts commit 1b28d0b10e1c8feccb971abb6ef7a18bee589830. llvm-svn: 296422
* Reland: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-281-2/+2
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296414
* Revert "[analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-271-2/+2
| | | | | | | | constraint managers" This reverts commit 8e7780b9e59ddaad1800baf533058d2c064d4787. llvm-svn: 296317
* [analyzer] NFC: Update test infrastructure to support multiple constraint ↵Dominic Chen2017-02-271-2/+2
| | | | | | | | | | | | | | managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296312
* [analyzer] Drop explicit mention of range constraint solverDominic Chen2016-12-011-1/+1
| | | | | | | | | | | | Summary: The basic constraint solver was dropped in rL162384, leaving the range constraint solver as the default and only constraint solver. Explicitly specifying it is unnecessary, and makes it difficult to test with other solver backends. Reviewers: zaks.anna, dcoughlin Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26694 llvm-svn: 288372
* [analyzer] Skip checking blocks in dependent contexts.Devin Coughlin2015-11-181-2/+16
| | | | | | | | | | | Since we don't check functions in dependent contexts, we should skip blocks in those contexts as well. This avoids an assertion failure when the DeadStoresChecker attempts to evaluate an array subscript expression with a dependent name type. rdar://problem/23564220 llvm-svn: 253516
* [Static Analyzer] Lambda support.Gabor Horvath2015-09-111-0/+14
| | | | | | Differential Revision: http://reviews.llvm.org/D12652 llvm-svn: 247426
* Disable dead stores checker for template instantations. Fixes ↵Ted Kremenek2013-02-181-0/+18
| | | | | | <rdar://problem/13213575>. llvm-svn: 175425
* libAnalysis: Add a case for TypeAliasDecl in CFGRecStmtDeclVisitor.Jordan Rose2013-02-161-2/+9
| | | | | | | | | | | Neither of the current clients of CFGRecStmtDeclVisitor are doing anything with typedefs, so I assume type aliases (C++11 "using") can be safely ignored. This was causing assertion failures in the analyzer. <rdar://problem/13228440> llvm-svn: 175335
* Fix bad CFG construction bug when handling C++ 'try' statements.Ted Kremenek2012-11-131-0/+23
| | | | | | | | | | | | | | | | | 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
* Tweak DeadStoresChecker to not warn about dead stores to variables thatTed Kremenek2012-09-061-0/+17
| | | | | | | | | are used in EH code. Right now the CFG doesn't support exceptions well, so we need this hack to avoid bogus dead store warnings. Fixes <rdar://problem/12147586> llvm-svn: 163353
* Remove BasicConstraintManager. It hasn't been in active service for a while.Ted Kremenek2012-08-221-1/+0
| | | | | | | | As part of this change, I discovered that a few of our tests were not testing the RangeConstraintManager. Luckily all of those passed when I moved them over to use that constraint manager. llvm-svn: 162384
* Really remove FlatStoreManager and BasicStoreManager, this time from the ↵Ted Kremenek2011-07-281-2/+0
| | | | | | driver. Also remove associated tests. Sorry for the messy commits; this is the result of a botched Git merge. llvm-svn: 136422
* Re-enable the IdempotentOperations checker for --analyze, and put it and the ↵Ted Kremenek2011-03-121-5/+5
| | | | | | DeadStores checker into the "deadcode" group. llvm-svn: 127531
* [analyzer] Remove '-analyzer-check-objc-mem' flag, the nominee for best ↵Argyrios Kyrtzidis2011-02-281-4/+4
| | | | | | misnomer award. llvm-svn: 126676
* [analyzer] Move the DeadStores checker out of the 'core' package.Argyrios Kyrtzidis2011-02-281-5/+5
| | | | | | | -Now it gets enabled with '-analyzer-checker=DeadStores'. -The driver passes the above flag by default. llvm-svn: 126612
* Add -fcxx-exceptions to all tests that use C++ exceptions.Anders Carlsson2011-02-281-5/+5
| | | | llvm-svn: 126599
* [analyzer] Remove '-analyzer-experimental-internal-checks' flag, it doesn't ↵Argyrios Kyrtzidis2011-02-241-5/+5
| | | | | | have any checkers associated with it anymore. llvm-svn: 126440
* Pass -fexceptions to all tests that use try/catch/throw.Anders Carlsson2011-02-191-5/+5
| | | | llvm-svn: 126037
* [analyzer] Use the new registration mechanism on the ↵Argyrios Kyrtzidis2011-02-171-5/+5
| | | | | | | | | | | | | non-path-sensitive-checkers: DeadStoresChecker ObjCMethSigsChecker ObjCUnusedIvarsChecker SizeofPointerChecker ObjCDeallocChecker SecuritySyntaxChecker llvm-svn: 125779
* Don't emit a dead store for '++' operations unless it occurs with a return ↵Ted Kremenek2011-02-121-3/+3
| | | | | | | | statement. We've never seen any other cases that were real bugs. Fixes <rdar://problem/6962292>. llvm-svn: 125419
* Enhance AnalysisConsumer to also visit functionsTed Kremenek2011-01-201-0/+12
| | | | | | and methods defined within 'namespace X { ... }'. llvm-svn: 123921
* Add dead stores C++ test case that was previously asserting due to anTed Kremenek2010-06-251-0/+8
| | | | | | invalid source range for CXXNewExpr. llvm-svn: 106904
* Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.Ted Kremenek2010-02-051-4/+4
| | | | llvm-svn: 95348
* Rename -cc1 option '-warn-dead-stores' to '-analyzer-check-dead-stores'.Ted Kremenek2010-02-051-5/+5
| | | | llvm-svn: 95343
* Insulate these from changes to the default for -Wunreachable-code.Mike Stump2010-01-231-5/+5
| | | | llvm-svn: 94326
* Suppress dead store warnings involving objects initialized with ↵Ted Kremenek2009-12-231-0/+26
| | | | | | CXXExprTemporaries. llvm-svn: 91986
* Add (initial?) static analyzer support for handling C++ references.Ted Kremenek2009-12-161-6/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change was a lot bigger than I originally anticipated; among other things it requires us storing more information in the CFG to record what block-level expressions need to be evaluated as lvalues. The big change is that CFGBlocks no longer contain Stmt*'s by CFGElements. Currently CFGElements just wrap Stmt*, but they also store a bit indicating whether the block-level expression should be evalauted as an lvalue. DeclStmts involving the initialization of a reference require us treating the initialization expression as an lvalue, even though that information isn't recorded in the AST. Conceptually this change isn't that complicated, but it required bubbling up the data through the CFGBuilder, to GRCoreEngine, and eventually to GRExprEngine. The addition of CFGElement is also useful for when we want to handle more control-flow constructs or other data we want to keep in the CFG that isn't represented well with just a block of statements. In GRExprEngine, this patch introduces logic for evaluating the lvalues of references, which currently retrieves the internal "pointer value" that the reference represents. EvalLoad does a two stage load to catch null dereferences involving an invalid reference (although this could possibly be caught earlier during the initialization of a reference). Symbols are currently symbolicated using the reference type, instead of a pointer type, and special handling is required creating ElementRegions that layer on SymbolicRegions (see the changes to RegionStoreManager). Along the way, the DeadStoresChecker also silences warnings involving dead stores to references. This was the original change I introduced (which I wrote test cases for) that I realized caused GRExprEngine to crash. llvm-svn: 91501
* Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.Daniel Dunbar2009-12-151-5/+5
| | | | | | | | | - This is designed to make it obvious that %clang_cc1 is a "test variable" which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it can be useful to redefine what gets run as 'clang -cc1' (for example, to set a default target). llvm-svn: 91446
* Until we can make the dead stores checker smarter, dont' emit dead store ↵Ted Kremenek2009-12-151-0/+20
| | | | | | warnings for C++ objects (whose constructors/destructors have possible side-effects). llvm-svn: 91412
* Replace clang-cc with clang -cc1.Zhongxing Xu2009-12-141-5/+5
| | | | llvm-svn: 91272
* Add clang-cc option "--analyzer-experimental-internal-checks". ThisTed Kremenek2009-11-131-5/+5
| | | | | | | option enables new "internal" checks that will eventually be turned on by default but still require broader testing. llvm-svn: 88671
* Eliminate &&s in tests.Daniel Dunbar2009-11-081-4/+4
| | | | | | - 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious. llvm-svn: 86430
* Remove 'StoreManager::OldCastRegion()', TypedViewRegion (which onlyTed Kremenek2009-07-291-2/+0
| | | | | | | OldCastRegion used), and the associated command line option '-analyzer-store=old-basic-cast'. llvm-svn: 77509
* Improve CFG support for C++ throw expressions.Mike Stump2009-07-221-0/+21
llvm-svn: 76814
OpenPOWER on IntegriCloud