diff options
| author | Ted Kremenek <kremenek@apple.com> | 2014-03-29 00:35:20 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2014-03-29 00:35:20 +0000 |
| commit | ec3bbf4933d70fd1c907f883acd45da4ab1f10ee (patch) | |
| tree | dcd8e6bb16ecfd1b1d0da0b1e308b6bf44956d63 /clang/lib/Analysis/CFG.cpp | |
| parent | fdf496cb4807647276ad43f9c4ae5aa30bad299c (diff) | |
| download | bcm5719-llvm-ec3bbf4933d70fd1c907f883acd45da4ab1f10ee.tar.gz bcm5719-llvm-ec3bbf4933d70fd1c907f883acd45da4ab1f10ee.zip | |
Improve -Wunreachable-code to provide a means to indicate code is 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
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
| -rw-r--r-- | clang/lib/Analysis/CFG.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index ad5cf69cd70..13ac92e86f2 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -4112,7 +4112,7 @@ void CFGBlock::printTerminator(raw_ostream &OS, TPrinter.print(getTerminator()); } -Stmt *CFGBlock::getTerminatorCondition() { +Stmt *CFGBlock::getTerminatorCondition(bool StripParens) { Stmt *Terminator = this->Terminator; if (!Terminator) return NULL; @@ -4171,6 +4171,9 @@ Stmt *CFGBlock::getTerminatorCondition() { return Terminator; } + if (!StripParens) + return E; + return E ? E->IgnoreParens() : NULL; } |

