diff options
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 7817ca9efc5..26fa4cddd31 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -1284,15 +1284,13 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList &AL) { } // Check we don't have a conflict with another ownership attribute. - for (specific_attr_iterator<OwnershipAttr> - i = D->specific_attr_begin<OwnershipAttr>(), - e = D->specific_attr_end<OwnershipAttr>(); i != e; ++i) { + for (const auto *I : D->specific_attrs<OwnershipAttr>()) { // FIXME: A returns attribute should conflict with any returns attribute // with a different index too. - if ((*i)->getOwnKind() != K && (*i)->args_end() != - std::find((*i)->args_begin(), (*i)->args_end(), Idx)) { + if (I->getOwnKind() != K && I->args_end() != + std::find(I->args_begin(), I->args_end(), Idx)) { S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible) - << AL.getName() << *i; + << AL.getName() << I; return; } } @@ -2445,18 +2443,14 @@ FormatAttr *Sema::mergeFormatAttr(Decl *D, SourceRange Range, int FirstArg, unsigned AttrSpellingListIndex) { // Check whether we already have an equivalent format attribute. - for (specific_attr_iterator<FormatAttr> - i = D->specific_attr_begin<FormatAttr>(), - e = D->specific_attr_end<FormatAttr>(); - i != e ; ++i) { - FormatAttr *f = *i; - if (f->getType() == Format && - f->getFormatIdx() == FormatIdx && - f->getFirstArg() == FirstArg) { + for (auto *F : D->specific_attrs<FormatAttr>()) { + if (F->getType() == Format && + F->getFormatIdx() == FormatIdx && + F->getFirstArg() == FirstArg) { // If we don't have a valid location for this attribute, adopt the // location. - if (f->getLocation().isInvalid()) - f->setRange(Range); + if (F->getLocation().isInvalid()) + F->setRange(Range); return NULL; } } @@ -2667,10 +2661,8 @@ static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &Attr) { return; // Don't duplicate annotations that are already set. - for (specific_attr_iterator<AnnotateAttr> - i = D->specific_attr_begin<AnnotateAttr>(), - e = D->specific_attr_end<AnnotateAttr>(); i != e; ++i) { - if ((*i)->getAnnotation() == Str) + for (const auto *I : D->specific_attrs<AnnotateAttr>()) { + if (I->getAnnotation() == Str) return; } @@ -2819,13 +2811,11 @@ void Sema::CheckAlignasUnderalignment(Decl *D) { // would otherwise be required for the entity being declared. AlignedAttr *AlignasAttr = 0; unsigned Align = 0; - for (specific_attr_iterator<AlignedAttr> - I = D->specific_attr_begin<AlignedAttr>(), - E = D->specific_attr_end<AlignedAttr>(); I != E; ++I) { + for (auto *I : D->specific_attrs<AlignedAttr>()) { if (I->isAlignmentDependent()) return; if (I->isAlignas()) - AlignasAttr = *I; + AlignasAttr = I; Align = std::max(Align, I->getAlignment(Context)); } |

