aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-08-06 03:04:42 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-08-06 03:04:42 +0000
commit22d4fed17df02f5fa07165a69228b0b0f1a73a28 (patch)
tree6aa9ceba0c6c0ea8536dffe98411ea687f7f9f4c /lib/Sema/SemaChecking.cpp
parent7d11c3f691674177bc7308c0fc6c82cb745bed0b (diff)
Only look at decls after the current one when checking if it's the last field in a record.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137009 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 8dfcfe7c11..d3332f7b56 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -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,