r204376 - [-Wunreachable-code] Tweak isTrivialDoWhile() to handle implicit casts.
Ted Kremenek
kremenek at apple.com
Thu Mar 20 11:47:53 PDT 2014
Author: kremenek
Date: Thu Mar 20 13:47:53 2014
New Revision: 204376
URL: http://llvm.org/viewvc/llvm-project?rev=204376&view=rev
Log:
[-Wunreachable-code] Tweak isTrivialDoWhile() to handle implicit casts.
Modified:
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/test/SemaCXX/warn-unreachable.cpp
Modified: cfe/trunk/lib/Analysis/ReachableCode.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ReachableCode.cpp?rev=204376&r1=204375&r2=204376&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ReachableCode.cpp (original)
+++ cfe/trunk/lib/Analysis/ReachableCode.cpp Thu Mar 20 13:47:53 2014
@@ -51,7 +51,7 @@ static bool isTrivialDoWhile(const CFGBl
// condition.
if (const Stmt *Term = B->getTerminator()) {
if (const DoStmt *DS = dyn_cast<DoStmt>(Term)) {
- const Expr *Cond = DS->getCond();
+ const Expr *Cond = DS->getCond()->IgnoreParenCasts();
return Cond == S && isTrivialExpression(Cond);
}
}
Modified: cfe/trunk/test/SemaCXX/warn-unreachable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unreachable.cpp?rev=204376&r1=204375&r2=204376&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unreachable.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unreachable.cpp Thu Mar 20 13:47:53 2014
@@ -218,6 +218,14 @@ int test_treat_non_const_bool_local_as_n
return 0;
}
+void test_do_while(int x) {
+ // Handle trivial expressions with
+ // implicit casts to bool.
+ do {
+ break;
+ } while (0); // no-warning
+}
+
class Frobozz {
public:
Frobozz(int x);
More information about the cfe-commits
mailing list