summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/warn-unreachable.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve -Wtautological-overlap-compareRichard Trieu2019-09-211-1/+1
| | | | | | | | | 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
* Teach Wreturn-type, Wunreachable-code, and alpha.deadcode.UnreachableCode to ↵Nico Weber2018-02-131-0/+4
| | | | | | | | | treat __assume(0) like __builtin_unreachable. Fixes PR29134. https://reviews.llvm.org/D43221 llvm-svn: 325052
* Fix PR13910: Don't warn that __builtin_unreachable() is unreachableAlex Lorenz2017-04-111-0/+37
| | | | | | Differential Revision: https://reviews.llvm.org/D25321 llvm-svn: 299951
* -Wunreachable-code: 'true' and 'false' should not be treated as configurationAlex Lorenz2017-04-051-0/+10
| | | | | | | | | macros Clang should emit -Wunreachable-code warnings in C mode for code that's unreachable because of a 'false' or '!true' condition. llvm-svn: 299541
* Avoid multiple -Wunreachable-code diagnostics that are triggered byAlex Lorenz2017-01-121-0/+55
| | | | | | | | | | | the same source range and use the unary operator fixit only when it actually silences the warning. rdar://24570531 Differential Revision: https://reviews.llvm.org/D28231 llvm-svn: 291757
* Fix some typosAlp Toker2014-05-051-2/+2
| | | | llvm-svn: 207994
* Improve -Wunreachable-code to provide a means to indicate code is ↵Ted Kremenek2014-03-291-2/+33
| | | | | | | | | | | | | | | | | | 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
* Further refine -Wunreachable-code groups so that -Wno-unreachable-code-break ↵Ted Kremenek2014-03-151-9/+49
| | | | | | | | | | 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] Handle 'return' with no argument dominated by ↵Ted Kremenek2014-03-081-0/+5
| | | | | | 'noreturn' function. llvm-svn: 203333
* [-Wunreachable-code] Correctly expand artificial reachability to pruned '&&' ↵Ted Kremenek2014-03-071-2/+2
| | | | | | and '||' branches involving configuration values. llvm-svn: 203194
* [-Wunreachable-code] Teach reachable code analysis heuristics about more ↵Ted Kremenek2014-03-071-1/+13
| | | | | | literal types. llvm-svn: 203193
* [-Wunreachable-code] Refine treating all branches of 'switch' as reachable, ↵Ted Kremenek2014-03-061-0/+11
| | | | | | which includes those with all cases covered but with no 'default:'. llvm-svn: 203094
* [-Wunreachable-code] Handle idiomatic do...while() with an uninteresting ↵Ted Kremenek2014-03-061-1/+2
| | | | | | | | | | condition. Sometimes do..while() is used to create a scope that can be left early. In such cases, the unreachable 'while()' test is not usually interesting unless it actually does something that is observable. llvm-svn: 203051
* [-Wunreachable-code] Handle idiomatic do...while() with an uninteresting ↵Ted Kremenek2014-03-061-2/+24
| | | | | | | | | | condition. Sometimes do..while() is used to create a scope that can be left early. In such cases, the unreachable 'while()' test is not usually interesting unless it actually does something that is observable. llvm-svn: 203036
* [-Wunreachable-code] generalize pruning out warning on trivial returns.Ted Kremenek2014-03-051-1/+22
| | | | | | | | Previously we only pruned dead returns preceded by a call to a 'noreturn' function. After looking at the results of the LLVM codebase, there are many others that should be pruned as well. llvm-svn: 203029
* [-Wunreachabe-code] add test for double 'break'.Ted Kremenek2014-03-051-0/+1
| | | | llvm-svn: 203027
* [-Wunreachable-code] include some enum constants in "configuration value" ↵Ted Kremenek2014-03-051-0/+18
| | | | | | heuristic llvm-svn: 203026
* [-Wunreachable-code] generalize configuration value checking to all ↵Ted Kremenek2014-03-051-0/+8
| | | | | | comparison operators. llvm-svn: 203016
* [-Wunreachable-code] Don't warn about dead code guarded by a "configuration ↵Ted Kremenek2014-03-051-1/+24
| | | | | | | | | | | | | | | value". Some unreachable code is only "sometimes unreachable" because it is guarded by a configuration value that is determined at compile time and is always constant. Sometimes those represent real bugs, but often they do not. This patch causes the reachability analysis to cover such branches even if they are technically unreachable in the CFG itself. There are some conservative heuristics at play here to determine a "configuration value"; these are intended to be refined over time. llvm-svn: 202912
* [-Wunreachable-code] always treat 'case:' and 'default:' cases as reachable.Ted Kremenek2014-02-271-0/+3
| | | | | | | | | | | This is a heuristic. Many switch statements, although they look covered over an enum, may actually handle at runtime more values than in the enum. This is overly conservative, as there are some cases that clearly can be ruled as being clearly unreachable, e.g. 'switch (42) { case 1: ... }'. We can refine this later. llvm-svn: 202436
* [-Wunreachable-code] Don't warn about trivially unreachable return ↵Ted Kremenek2014-02-271-0/+13
| | | | | | statements preceded by 'noreturn' functions. llvm-svn: 202352
* Fix test case indentation.Ted Kremenek2014-02-271-1/+1
| | | | llvm-svn: 202351
* [-Wunreachable-code] Don't warn about unreachable 'default:' cases.Ted Kremenek2014-02-271-1/+24
| | | | | | They are covered by -Wcovered-switch-default. llvm-svn: 202349
* [-Wunreachable-code] Prune out unreachable warnings where a 'break' is ↵Ted Kremenek2014-02-271-0/+21
| | | | | | | | | | | | | | | preceded by a call to a 'noreturn' function. For example: unreachable(); break; This code is idiomatic and defensive. The fact that 'break' is unreachable here is not interesting. This occurs frequently in LLVM/Clang itself. llvm-svn: 202328
* Add test that -Wunreachable-code warnings are suppressed in headers.Ted Kremenek2014-02-211-1/+3
| | | | llvm-svn: 201893
* Forbid driver use in Sema testsAlp Toker2014-01-161-1/+1
| | | | | | | | This ports the last Sema tests over to use the frontend directly, and adds a local lit substitution to disable inappropriate %clang usage under this directory. llvm-svn: 199348
* Change subexpressions to be visited in the CFG from left-to-right.Ted Kremenek2013-02-051-4/+4
| | | | | | | | | | | | | | | | | This is a more natural order of evaluation, and it is very important for visualization in the static analyzer. Within Xcode, the arrows will not jump from right to left, which looks very visually jarring. It also provides a more natural location for dataflow-based diagnostics. Along the way, we found a case in the analyzer diagnostics where we needed to indicate that a variable was "captured" by a block. -fsyntax-only timings on sqlite3.c show no visible performance change, although this is just one test case. Fixes <rdar://problem/13016513> llvm-svn: 174447
* Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.Ted Kremenek2012-08-241-0/+9
| | | | | | Fixes <rdar://problem/11005770>. llvm-svn: 162545
* Reword/rename -Wswitch-unreachable-default.David Blaikie2012-01-241-1/+1
| | | | | | | | Rewording the diagnostic to be more precise/correct: "default label in switch which covers all enumeration values" and changed the switch to -Wcovered-switch-default llvm-svn: 148783
* Rename -Wswitch-enum-redundant-default to -Wswitch-redundant-default.David Blaikie2012-01-231-1/+1
| | | | | | | | This is for consistency, since the flag is actually under -Wswitch now, rather than -Wswitch-enum (since it's really valuable for the former and rather orthogonal to the latter) llvm-svn: 148680
* Add -Wswitch-enum-redundant-default.David Blaikie2012-01-211-1/+1
| | | | | | | | | | | | | | | | | | | This warning acts as the complement to the main -Wswitch-enum warning (which warns whenever a switch over enum without a default doesn't cover all values of the enum) & has been an an-doc coding convention in LLVM and Clang in my experience. The purpose is to ensure there's never a "dead" default in a switch-over-enum because this would hide future -Wswitch-enum errors. The name warning has a separate flag name so it can be disabled but it's grouped under -Wswitch-enum & is on-by-default because of this. The existing violations of this rule in test cases have had the warning disabled & I've added a specific test for the new behavior (many negative cases already exist in the same test file - and none regressed - so I didn't add more). Reviewed by Ted Kremenek ( http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120116/051690.html ) llvm-svn: 148640
* Add test case for PR 9774, which got fixed along the way.Ted Kremenek2012-01-031-0/+6
| | | | llvm-svn: 147479
* Teach -Wunreachable-code about dead code caused by macro expansions. This ↵Ted Kremenek2011-08-251-0/+12
| | | | | | should suppress false positives resulting from 'assert' and friends. llvm-svn: 138576
* 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
* - Fixed subexpressions evaluation order for binary operators to match order ↵Marcin Swiderski2010-10-241-4/+4
| | | | | | | | in code generated with the compiler, - Fixed test cases for unreachable code warnings produced by Sema. llvm-svn: 117220
* Enhance -Wunreachable-code to not consider the 'default:' branch of a switch ↵Ted Kremenek2010-09-091-0/+16
| | | | | | | | statement live if a switch on an enum value has explicit 'case:' statements for each enum value. llvm-svn: 113451
* Get rid of the "functions declared 'noreturn' should have a 'void' result ↵Anders Carlsson2010-09-031-1/+1
| | | | | | | | | 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-1/+1
| | | | | | non-void result. (<rdar://problem/7562925>) llvm-svn: 111492
* 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/+6
| | | | | | dead array references. llvm-svn: 94115
* Improve unreachable code warnings for with respect to c-style casts.Mike Stump2010-01-211-0/+3
| | | | llvm-svn: 94094
* Improve unreachable code warnings for with respect to ? :.Mike Stump2010-01-211-0/+4
| | | | llvm-svn: 94093
* Improve unreachable code warnings for with respect to compoundMike Stump2010-01-211-0/+5
| | | | | | assignments. llvm-svn: 94086
* Improve unreachable code warnings with respect to dead binary andMike Stump2010-01-211-4/+10
| | | | | | unary operators. llvm-svn: 94084
* Generalize handling for unreachable code warnings to all binary operators.Mike Stump2010-01-151-4/+4
| | | | llvm-svn: 93584
* Refine location reporting for unreachable code warnings for comma expressions.Mike Stump2010-01-151-0/+56
| | | | llvm-svn: 93574
* Add testcase for recent checkin.Mike Stump2010-01-151-0/+20
llvm-svn: 93503
OpenPOWER on IntegriCloud