[PATCH] D24010: [ReachableCode] Skip over ExprWithCleanups in isConfigurationValue
Tim Shen via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 29 15:44:50 PDT 2016
timshen created this revision.
timshen added reviewers: rsmith, pirama.
timshen added a subscriber: cfe-commits.
https://reviews.llvm.org/D24010
Files:
clang/include/clang/AST/Stmt.h
clang/lib/Analysis/ReachableCode.cpp
clang/test/SemaCXX/PR29152.cpp
Index: clang/test/SemaCXX/PR29152.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/PR29152.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunreachable-code -verify %s
+
+static const bool False = false;
+
+struct Vector {
+ struct iterator {
+ bool operator==(const iterator &) const;
+ };
+ iterator end();
+};
+
+void Bar();
+Vector::iterator Find(Vector &a);
+
+void Foo(Vector &a) {
+ if (False && Find(a) == a.end()) {
+ Bar(); // expected-no-diagnostics
+ }
+}
Index: clang/lib/Analysis/ReachableCode.cpp
===================================================================
--- clang/lib/Analysis/ReachableCode.cpp
+++ clang/lib/Analysis/ReachableCode.cpp
@@ -164,6 +164,8 @@
if (!S)
return false;
+ S = S->IgnoreImplicit();
+
if (const Expr *Ex = dyn_cast<Expr>(S))
S = Ex->IgnoreCasts();
Index: clang/include/clang/AST/Stmt.h
===================================================================
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -387,6 +387,9 @@
/// 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24010.69627.patch
Type: text/x-patch
Size: 1494 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160829/27b51821/attachment-0001.bin>
More information about the cfe-commits
mailing list