summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/warn-unreachable.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improve -Wtautological-overlap-compareRichard Trieu2019-09-211-2/+3
| | | | | | | | | Allow this warning to detect a larger number of constant values, including negative numbers, and handle non-int types better. Differential Revision: https://reviews.llvm.org/D66044 llvm-svn: 372448
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* Implement C++ [basic.link]p8.Richard Smith2017-09-201-6/+10
| | | | | | | | | | | | | | If a function or variable has a type with no linkage (and is not extern "C"), any use of it requires a definition within the same translation unit; the idea is that it is not possible to define the entity elsewhere, so any such use is necessarily an error. There is an exception, though: some types formally have no linkage but nonetheless can be referenced from other translation units (for example, this happens to anonymous structures defined within inline functions). For entities with those types, we suppress the diagnostic except under -pedantic. llvm-svn: 313729
* -Wunreachable-code: refine recognition of unreachable "sigil" to cope with ↵Ted Kremenek2014-04-161-0/+30
| | | | | | | | implicit casts in C++. Fixes <rdar://problem/16631033>. llvm-svn: 206360
* Add a new subgroup to -Wtautological-compare, -Wtautological-overlap-compare,Richard Trieu2014-04-051-1/+51
| | | | | | | | | | | | | | 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
* [-Wunreachable-code] Expand paren-suppression heuristic to C++/ObjC bools.Ted Kremenek2014-03-291-0/+33
| | | | llvm-svn: 205074
* [-Wunreachable-code] add a specialized diagnostic for unreachable increment ↵Ted Kremenek2014-03-211-0/+12
| | | | | | expressions of loops. llvm-svn: 204430
* [-Wunreachable-code] Tweak isTrivialDoWhile() to handle implicit casts.Ted Kremenek2014-03-201-0/+8
| | | | llvm-svn: 204376
* [-Wunreachable-code] Look through member accesses for 'static const bool' ↵Ted Kremenek2014-03-201-16/+35
| | | | | | configuration values. llvm-svn: 204315
* [-Wunreachable-code] constexpr functions can be used as configuration values.Ted Kremenek2014-03-201-1/+22
| | | | llvm-svn: 204308
* [-Wunreachable-code] Simplify and broad -Wunreachable-code-return, including ↵Ted Kremenek2014-03-201-0/+16
| | | | | | | | | | | | | | | | | nontrivial returns. The exception is return statements that include control-flow, which are clearly doing something "interesting". 99% of the cases I examined for -Wunreachable-code that fired on return statements were not interesting enough to warrant being in -Wunreachable-code by default. Thus the move to include them in -Wunreachable-code-return. This simplifies a bunch of logic, including removing the ad hoc logic to look for std::string literals. llvm-svn: 204307
* -Wunreachable-code: treat 'const bool' locals as control values.Ted Kremenek2014-03-151-0/+19
| | | | llvm-svn: 204001
* Further refine -Wunreachable-code groups so that -Wno-unreachable-code-break ↵Ted Kremenek2014-03-151-2/+2
| | | | | | | | | | doesn't turn off all unreachable code warnings. Also relax unreachable 'break' and 'return' to not check for being preceded by a call to 'noreturn'. That turns out to not be so interesting in practice. llvm-svn: 204000
* Start breaking -Wunreachable-code up into different diagnostic groups.Ted Kremenek2014-03-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent work on -Wunreachable-code has focused on suppressing uninteresting unreachable code that center around "configuration values", but there are still some set of cases that are sometimes interesting or uninteresting depending on the codebase. For example, a dead "break" statement may not be interesting for a particular codebase, potentially because it is auto-generated or simply because code is written defensively. To address these workflow differences, -Wunreachable-code is now broken into several diagnostic groups: -Wunreachable-code: intended to be a reasonable "default" for most users. and then other groups that turn on more aggressive checking: -Wunreachable-code-break: warn about dead break statements -Wunreachable-code-trivial-return: warn about dead return statements that return "trivial" values (e.g., return 0). Other return statements that return non-trivial values are still reported under -Wunreachable-code (this is an area subject to more refinement). -Wunreachable-code-aggressive: supergroup that enables all these groups. The goal is to eventually make -Wunreachable-code good enough to either be in -Wall or on-by-default, thus finessing these warnings into different groups helps achieve maximum signal for more users. TODO: the tests need to be updated to reflect this extra control via diagnostic flags. llvm-svn: 203994
* [-Wunreachable-code] Tweak heuristic for configuration values to include ↵Ted Kremenek2014-03-081-0/+24
| | | | | | | | | arithmetic operations involving sizeof(), but not raw integers. This case was motivated by a false positive with the llvm::AlignOf<> specialization in LLVM. llvm-svn: 203363
* [-Wunreachabe-code] Don't warn about unreachable destructors for temporaries.Ted Kremenek2014-03-081-0/+13
| | | | | | | | This can possibly be refined later, but right now the experience is so incomprehensible for a user to understand what is going on this isn't a useful warning. llvm-svn: 203336
* [-Wunreachable-code] Treat constant globals as configuration values in ↵Ted Kremenek2014-03-071-0/+7
| | | | | | | | | unreachable code heuristics. This one could possibly be refined even further; e.g. looking at the initializer and see if it is truly a configuration value. llvm-svn: 203283
* [-Wunreachable-code] Teach reachable code analysis heuristics about more ↵Ted Kremenek2014-03-071-0/+4
| | | | | | literal types. llvm-svn: 203193
* [-Wunreachable-code] don't warn about dead 'return <string literal>' ↵Ted Kremenek2014-03-061-0/+21
| | | | | | | | | | | | | dominated by a 'noreturn' call, where literal becomes an std::string. I have mixed feelings about this one. It's used all over the codebase, and is analogous to the current heuristic for ordinary C string literals. This requires some ad hoc pattern matching of the AST. While the test case mirrors what we see std::string in libc++, it's not really testing the libc++ headers. llvm-svn: 203091
* [-Wunreachable-code] handle cases where a dead 'return' may have a valid ↵Ted Kremenek2014-03-041-0/+23
| | | | | | | | predecessor. Fies PR19040. llvm-svn: 202892
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-2/+2
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* Revert various template unreachability code I committed accidentally.David Blaikie2012-01-241-34/+0
| | | | | | r148774, r148775, r148776, r148777 llvm-svn: 148780
* More fixes/tests.David Blaikie2012-01-241-0/+9
| | | | llvm-svn: 148777
* Test for the previous commit/crash.David Blaikie2012-01-241-0/+8
| | | | llvm-svn: 148776
* Simple hack to do unreachable code analysis on template patterns.David Blaikie2012-01-241-1/+18
| | | | llvm-svn: 148774
* Further tweak -Wurneachable-code and templates by allowing the warning to run onTed Kremenek2011-12-011-0/+9
| | | | | | | | | explicit template specializations (which represent actual functions somebody wrote). Along the way, refactor some other code which similarly cares about whether or not they are looking at a template instantiation. llvm-svn: 145547
* Don't run -Wunreachable-code on template instantiations. Different ↵Ted Kremenek2011-11-301-0/+22
| | | | | | instantiations may produce different unreachable code results, and it is very difficult for us to prove that ALL instantiations of a template have specific unreachable code. If we come up with a better solution, then we can revisit this, but this approach will at least greatly reduce the noise of this warning for code that makes use of templates. llvm-svn: 145520
* Reduce -Wuninitialized time by 22% (on sqlite) by removing the recursive AST ↵Ted Kremenek2011-07-191-4/+4
| | | | | | | | | | | | | | | crawl. This is accomplished by forcing the needed expressions for -Wuninitialized to always be CFGElements in the CFG. This allows us to remove a fair amount of the code for -Wuninitialized. Some fallout: - AnalysisBasedWarnings.cpp now specifically toggles the CFGBuilder to create a CFG that is suitable for -Wuninitialized. This is a layering violation, since the logic for -Wuninitialized is in libAnalysis. This can be fixed with the proper refactoring. - Some of the source locations for -Wunreachable-code warnings have shifted. While not ideal, this is okay because that analysis already needs some serious reworking. llvm-svn: 135480
* Add -fcxx-exceptions to all tests that use C++ exceptions.Anders Carlsson2011-02-281-1/+1
| | | | llvm-svn: 126599
* Pass -fexceptions to all tests that use try/catch/throw.Anders Carlsson2011-02-191-1/+1
| | | | llvm-svn: 126037
* Tweak location of diagnostic for -Wunreachable-codeTed Kremenek2010-12-161-2/+4
| | | | | | | | | | test due to recent changes to the CFG. The diagnostic is somewhat in the wrong place, but the -Wunreachable-code diagnostic needs to be revamped anyway since most of the diagnostics in this test case are redundant. llvm-svn: 121961
* Get rid of the "functions declared 'noreturn' should have a 'void' result ↵Anders Carlsson2010-09-031-2/+2
| | | | | | | | | type" warning. The rationale behind this is that it is normal for callback functions to have a non-void return type and it should still be possible to mark them noreturn. (JavaScriptCore is a good example of this). llvm-svn: 112918
* Add warning for functions/blocks that have attribute 'noreturn' but return a ↵Ted Kremenek2010-08-191-2/+2
| | | | | | non-void result. (<rdar://problem/7562925>) llvm-svn: 111492
* tests: Use %clangxx when using driver for C++, in case C++ support is disabled.Daniel Dunbar2010-06-291-1/+1
| | | | llvm-svn: 107153
* Always add CallExpr as block-level expression. Inline-based interproceduralZhongxing Xu2010-02-241-2/+2
| | | | | | analysis needs this. llvm-svn: 97014
* Improve unreachable code warnings with respect to dead member andMike Stump2010-01-211-0/+28
| | | | | | dead array references. llvm-svn: 94115
* Improve unreachable code warnings for with respect to dead functional casts ↵Mike Stump2010-01-211-1/+4
| | | | | | in C++. llvm-svn: 94106
* Improve unreachable code warnings for with respect to ? :.Mike Stump2010-01-211-0/+3
| | | | llvm-svn: 94093
* Improve unreachable code warnings with respect to dead binary andMike Stump2010-01-211-1/+8
| | | | | | unary operators. llvm-svn: 94084
* Speed up compilation by avoiding generating exceptional edges fromMike Stump2010-01-211-0/+35
CallExprs as those edges help cause a n^2 explosion in the number of destructor calls. Other consumers, such as static analysis, that would like to have more a more complete CFG can select the inclusion of those edges as CFG build time. This also fixes up the two compilation users of CFGs to be tolerant of having or not having those edges. All catch code is assumed be to live if we didn't generate the exceptional edges for CallExprs. llvm-svn: 94074
OpenPOWER on IntegriCloud