]> granicus.if.org Git - clang/commitdiff
Only look at decls after the current one when checking if it's the last field in...
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 6 Aug 2011 03:04:42 +0000 (03:04 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 6 Aug 2011 03:04:42 +0000 (03:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137009 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp

index 8dfcfe7c1141e20da24db9c4dfa3916fc2c40209..d3332f7b56094c04b36e7f33747a5858b42f3f87 100644 (file)
@@ -3512,16 +3512,12 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size,
   if (!RD || !RD->isStruct())
     return false;
 
-  // This is annoyingly inefficient. We don't have a bi-directional iterator
-  // here so we can't walk backwards through the decls, we have to walk
-  // forward.
-  for (RecordDecl::field_iterator FI = RD->field_begin(),
-                                  FEnd = RD->field_end();
-       FI != FEnd; ++FI) {
-    if (*FI == FD)
-      return ++FI == FEnd;
-  }
-  return false;
+  // See if this is the last field decl in the record.
+  const Decl *D = FD;
+  while ((D = D->getNextDeclInContext()))
+    if (isa<FieldDecl>(D))
+      return false;
+  return true;
 }
 
 void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,