diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-08-06 03:04:42 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-08-06 03:04:42 +0000 |
commit | 8c54367935d6605810ae5d501e5dc0d64389f6b1 (patch) | |
tree | a3478acac6c0a0e7cefd9865988c4f8e749e3b34 /clang/lib/Sema/SemaChecking.cpp | |
parent | 2d0e7a4a2e5deec5368276c6da27c24efeee7aae (diff) | |
download | bcm5719-llvm-8c54367935d6605810ae5d501e5dc0d64389f6b1.tar.gz bcm5719-llvm-8c54367935d6605810ae5d501e5dc0d64389f6b1.zip |
Only look at decls after the current one when checking if it's the last field in a record.
llvm-svn: 137009
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 8dfcfe7c114..d3332f7b560 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/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, |