summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Sema/SemaStmt.cpp12
-rw-r--r--clang/test/SemaObjC/warn-loop-analysis.m15
2 files changed, 27 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index b73b4f08841..1975fcb1102 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1440,6 +1440,18 @@ namespace {
FoundDecl = true;
}
+ void VisitPseudoObjectExpr(PseudoObjectExpr *POE) {
+ // Only need to visit the semantics for POE.
+ // SyntaticForm doesn't really use the Decal.
+ for (auto *S : POE->semantics()) {
+ if (auto *OVE = dyn_cast<OpaqueValueExpr>(S))
+ // Look past the OVE into the expression it binds.
+ Visit(OVE->getSourceExpr());
+ else
+ Visit(S);
+ }
+ }
+
bool FoundDeclInUse() { return FoundDecl; }
}; // end class DeclMatcher
diff --git a/clang/test/SemaObjC/warn-loop-analysis.m b/clang/test/SemaObjC/warn-loop-analysis.m
new file mode 100644
index 00000000000..8ae7375f7f2
--- /dev/null
+++ b/clang/test/SemaObjC/warn-loop-analysis.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s
+// expected-no-diagnostics
+
+@interface MyArray
+- (id)objectAtIndexedSubscript:(unsigned int)idx;
+@end
+
+// Do not warn on objc classes has objectAtIndexedSubscript method.
+MyArray *test;
+void foo()
+{
+ unsigned int i;
+ for (i = 42; i > 0;) // No warnings here
+ (void)test[--i];
+}
OpenPOWER on IntegriCloud