aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2016-11-01 00:19:04 +0000
committerTim Shen <timshen91@gmail.com>2016-11-01 00:19:04 +0000
commit43ee05e804b89ea06ce3fe25d70e4a662e2f4518 (patch)
tree14f281abafb2fcd2ceabd057e9d288a13a13292c
parent70c5f02d25d29b1330b2747352994812d802aeaf (diff)
downloadllvm-43ee05e804b89ea06ce3fe25d70e4a662e2f4518.zip
llvm-43ee05e804b89ea06ce3fe25d70e4a662e2f4518.tar.gz
llvm-43ee05e804b89ea06ce3fe25d70e4a662e2f4518.tar.bz2
[ReachableCode] Skip over ExprWithCleanups in isConfigurationValue
Summary: Fixes pr29152. Reviewers: rsmith, pirama, krememek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D24010 llvm-svn: 285657
-rw-r--r--clang/include/clang/AST/Stmt.h3
-rw-r--r--clang/lib/Analysis/ReachableCode.cpp2
-rw-r--r--clang/test/SemaCXX/PR29152.cpp15
3 files changed, 20 insertions, 0 deletions
diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 9381a44..e28675d 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@ public:
/// Skip past any implicit AST nodes which might surround this
/// statement, such as ExprWithCleanups or ImplicitCastExpr nodes.
Stmt *IgnoreImplicit();
+ const Stmt *IgnoreImplicit() const {
+ return const_cast<Stmt *>(this)->IgnoreImplicit();
+ }
/// \brief Skip no-op (attributed, compound) container stmts and skip captured
/// stmt at the top, if \a IgnoreCaptured is true.
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp
index 8165b09..69d000c0 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@ static bool isConfigurationValue(const Stmt *S,
if (!S)
return false;
+ S = S->IgnoreImplicit();
+
if (const Expr *Ex = dyn_cast<Expr>(S))
S = Ex->IgnoreCasts();
diff --git a/clang/test/SemaCXX/PR29152.cpp b/clang/test/SemaCXX/PR29152.cpp
new file mode 100644
index 0000000..63c9c9b
--- /dev/null
+++ b/clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct A {
+ ~A();
+ operator bool();
+};
+void Bar();
+
+void Foo() {
+ if (False && A()) {
+ Bar(); // expected-no-diagnostics
+ }
+}