[cfe-commits] r137009 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Benjamin Kramer benny.kra at googlemail.com
Fri Aug 5 20:04:42 PDT 2011


Author: d0k
Date: Fri Aug  5 22:04:42 2011
New Revision: 137009

URL: http://llvm.org/viewvc/llvm-project?rev=137009&view=rev
Log:
Only look at decls after the current one when checking if it's the last field in a record.

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=137009&r1=137008&r2=137009&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Aug  5 22:04:42 2011
@@ -3512,16 +3512,12 @@
   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,





More information about the cfe-commits mailing list