From: Aaron Ballman Date: Fri, 7 Mar 2014 13:13:38 +0000 (+0000) Subject: Fully reverting r203236 -- it seems the only bots that are happy are the MSVC bots. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32e45c49cd817a38a59bddacd524062717b1081b;p=clang Fully reverting r203236 -- it seems the only bots that are happy are the MSVC bots. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203237 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DataRecursiveASTVisitor.h b/include/clang/AST/DataRecursiveASTVisitor.h index 37a5c8e86d..f3481c15bf 100644 --- a/include/clang/AST/DataRecursiveASTVisitor.h +++ b/include/clang/AST/DataRecursiveASTVisitor.h @@ -598,8 +598,8 @@ bool DataRecursiveASTVisitor::TraverseDecl(Decl *D) { } // Visit any attributes attached to this declaration. - for (auto I : D->attrs()) { - if (!getDerived().TraverseAttr(I)) + for (Decl::attr_iterator I=D->attr_begin(), E=D->attr_end(); I != E; ++I) { + if (!getDerived().TraverseAttr(*I)) return false; } return true; diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index ac1945cc3c..d281f19df8 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -18,7 +18,6 @@ #include "clang/AST/DeclarationName.h" #include "clang/Basic/Linkage.h" #include "clang/Basic/Specifiers.h" -#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Compiler.h" @@ -448,23 +447,14 @@ public: } typedef AttrVec::const_iterator attr_iterator; - typedef llvm::iterator_range attr_range; - - attr_range attrs() const { - // FIXME: Do not rely on iterators having comparable singular values. - // Note that this should error out if they do not. - if (!hasAttrs()) - return attr_range(); - - auto const &A = getAttrs(); - return attr_range(A.begin(), A.end()); - } + // FIXME: Do not rely on iterators having comparable singular values. + // Note that this should error out if they do not. attr_iterator attr_begin() const { - return attrs().begin(); + return hasAttrs() ? getAttrs().begin() : 0; } attr_iterator attr_end() const { - return attrs().end(); + return hasAttrs() ? getAttrs().end() : 0; } template diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 86537b0966..92c26c4235 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -669,8 +669,8 @@ bool RecursiveASTVisitor::TraverseDecl(Decl *D) { } // Visit any attributes attached to this declaration. - for (auto I : D->attrs()) { - if (!getDerived().TraverseAttr(I)) + for (Decl::attr_iterator I=D->attr_begin(), E=D->attr_end(); I != E; ++I) { + if (!getDerived().TraverseAttr(*I)) return false; } return true; diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 810560d57f..42edf5bb94 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -762,7 +762,7 @@ void ASTDumper::dumpDecl(const Decl *D) { if (ND->isHidden()) OS << " hidden"; - bool HasAttrs = D->hasAttrs(); + bool HasAttrs = D->attr_begin() != D->attr_end(); const FullComment *Comment = D->getASTContext().getLocalCommentForDeclUncached(D); // Decls within functions are visited by the body diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 872a26d022..6eaf140550 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -3501,8 +3501,8 @@ LabelDecl *LabelDecl::CreateDeserialized(ASTContext &C, unsigned ID) { void ValueDecl::anchor() { } bool ValueDecl::isWeak() const { - for (auto I : attrs()) - if (isa(I) || isa(I)) + for (attr_iterator I = attr_begin(), E = attr_end(); I != E; ++I) + if (isa(*I) || isa(*I)) return true; return isWeakImported(); diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 873e986d79..00692df46c 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -408,8 +408,8 @@ AvailabilityResult Decl::getAvailability(std::string *Message) const { AvailabilityResult Result = AR_Available; std::string ResultMessage; - for (auto A : attrs()) { - if (auto Deprecated = dyn_cast(A)) { + for (attr_iterator A = attr_begin(), AEnd = attr_end(); A != AEnd; ++A) { + if (DeprecatedAttr *Deprecated = dyn_cast(*A)) { if (Result >= AR_Deprecated) continue; @@ -420,13 +420,13 @@ AvailabilityResult Decl::getAvailability(std::string *Message) const { continue; } - if (auto Unavailable = dyn_cast(A)) { + if (UnavailableAttr *Unavailable = dyn_cast(*A)) { if (Message) *Message = Unavailable->getMessage(); return AR_Unavailable; } - if (auto Availability = dyn_cast(A)) { + if (AvailabilityAttr *Availability = dyn_cast(*A)) { AvailabilityResult AR = CheckAvailability(getASTContext(), Availability, Message); @@ -482,11 +482,11 @@ bool Decl::isWeakImported() const { if (!canBeWeakImported(IsDefinition)) return false; - for (auto A : attrs()) { - if (isa(A)) + for (attr_iterator A = attr_begin(), AEnd = attr_end(); A != AEnd; ++A) { + if (isa(*A)) return true; - if (AvailabilityAttr *Availability = dyn_cast(A)) { + if (AvailabilityAttr *Availability = dyn_cast(*A)) { if (CheckAvailability(getASTContext(), Availability, 0) == AR_NotYetIntroduced) return true; diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 887b93ab58..28f85d7a9f 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -2638,11 +2638,12 @@ CodeCompletionResult::CreateCodeCompletionString(ASTContext &Ctx, return Result.TakeString(); } - for (auto i = ND->specific_attr_begin(), - e = ND->specific_attr_end(); i != e; ++i) - Result.AddAnnotation( - Result.getAllocator().CopyString((*i)->getAnnotation())); - + for (Decl::attr_iterator i = ND->attr_begin(); i != ND->attr_end(); ++i) { + if (AnnotateAttr *Attr = dyn_cast_or_null(*i)) { + Result.AddAnnotation(Result.getAllocator().CopyString(Attr->getAnnotation())); + } + } + AddResultTypeChunk(Ctx, Policy, ND, Result); if (const FunctionDecl *Function = dyn_cast(ND)) { diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index f0a24301d5..9840d1eca1 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1791,16 +1791,16 @@ void Sema::MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls) { static bool DeclHasAttr(const Decl *D, const Attr *A) { const OwnershipAttr *OA = dyn_cast(A); const AnnotateAttr *Ann = dyn_cast(A); - for (auto i : D->attrs()) - if (i->getKind() == A->getKind()) { + for (Decl::attr_iterator i = D->attr_begin(), e = D->attr_end(); i != e; ++i) + if ((*i)->getKind() == A->getKind()) { if (Ann) { - if (Ann->getAnnotation() == cast(i)->getAnnotation()) + if (Ann->getAnnotation() == cast(*i)->getAnnotation()) return true; continue; } // FIXME: Don't hardcode this check - if (OA && isa(i)) - return OA->getOwnKind() == cast(i)->getOwnKind(); + if (OA && isa(*i)) + return OA->getOwnKind() == cast(*i)->getOwnKind(); return true; } @@ -1997,9 +1997,12 @@ static const Decl *getDefinition(const Decl *D) { } static bool hasAttribute(const Decl *D, attr::Kind Kind) { - for (auto Attribute : D->attrs()) + for (Decl::attr_iterator I = D->attr_begin(), E = D->attr_end(); + I != E; ++I) { + Attr *Attribute = *I; if (Attribute->getKind() == Kind) return true; + } return false; } diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 0b83427067..2d35d5cda7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -12723,41 +12723,48 @@ bool Sema::checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method) { FindCXXThisExpr Finder(*this); // Check attributes. - for (auto A : Method->attrs()) { + for (Decl::attr_iterator A = Method->attr_begin(), AEnd = Method->attr_end(); + A != AEnd; ++A) { // FIXME: This should be emitted by tblgen. Expr *Arg = 0; ArrayRef Args; - if (auto G = dyn_cast(A)) + if (GuardedByAttr *G = dyn_cast(*A)) Arg = G->getArg(); - else if (auto G = dyn_cast(A)) + else if (PtGuardedByAttr *G = dyn_cast(*A)) Arg = G->getArg(); - else if (auto AA = dyn_cast(A)) + else if (AcquiredAfterAttr *AA = dyn_cast(*A)) Args = ArrayRef(AA->args_begin(), AA->args_size()); - else if (auto AB = dyn_cast(A)) + else if (AcquiredBeforeAttr *AB = dyn_cast(*A)) Args = ArrayRef(AB->args_begin(), AB->args_size()); - else if (auto ELF = dyn_cast(A)) + else if (ExclusiveLockFunctionAttr *ELF + = dyn_cast(*A)) Args = ArrayRef(ELF->args_begin(), ELF->args_size()); - else if (auto SLF = dyn_cast(A)) + else if (SharedLockFunctionAttr *SLF + = dyn_cast(*A)) Args = ArrayRef(SLF->args_begin(), SLF->args_size()); - else if (auto ETLF = dyn_cast(A)) { + else if (ExclusiveTrylockFunctionAttr *ETLF + = dyn_cast(*A)) { Arg = ETLF->getSuccessValue(); Args = ArrayRef(ETLF->args_begin(), ETLF->args_size()); - } else if (auto STLF = dyn_cast(A)) { + } else if (SharedTrylockFunctionAttr *STLF + = dyn_cast(*A)) { Arg = STLF->getSuccessValue(); Args = ArrayRef(STLF->args_begin(), STLF->args_size()); - } else if (auto UF = dyn_cast(A)) + } else if (UnlockFunctionAttr *UF = dyn_cast(*A)) Args = ArrayRef(UF->args_begin(), UF->args_size()); - else if (auto LR = dyn_cast(A)) + else if (LockReturnedAttr *LR = dyn_cast(*A)) Arg = LR->getArg(); - else if (auto LE = dyn_cast(A)) + else if (LocksExcludedAttr *LE = dyn_cast(*A)) Args = ArrayRef(LE->args_begin(), LE->args_size()); - else if (auto RC = dyn_cast(A)) + else if (RequiresCapabilityAttr *RC + = dyn_cast(*A)) Args = ArrayRef(RC->args_begin(), RC->args_size()); - else if (auto AC = dyn_cast(A)) + else if (AcquireCapabilityAttr *AC = dyn_cast(*A)) Args = ArrayRef(AC->args_begin(), AC->args_size()); - else if (auto AC = dyn_cast(A)) - Args = ArrayRef(AC->args_begin(), AC->args_size()); - else if (auto RC = dyn_cast(A)) + else if (TryAcquireCapabilityAttr *AC + = dyn_cast(*A)) + Args = ArrayRef(AC->args_begin(), AC->args_size()); + else if (ReleaseCapabilityAttr *RC = dyn_cast(*A)) Args = ArrayRef(RC->args_begin(), RC->args_size()); if (Arg && !Finder.TraverseStmt(Arg)) diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 785aa6a1e2..c96fcbed53 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1940,11 +1940,13 @@ void Sema::DiagnoseMissingDesignatedInitOverrides( static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod, ObjCPropertyDecl *Property) { // Should we just clone all attributes over? - for (auto A : Property->attrs()) { - if (isa(A) || - isa(A) || - isa(A)) - PropertyMethod->addAttr(A->clone(S.Context)); + for (Decl::attr_iterator A = Property->attr_begin(), + AEnd = Property->attr_end(); + A != AEnd; ++A) { + if (isa(*A) || + isa(*A) || + isa(*A)) + PropertyMethod->addAttr((*A)->clone(S.Context)); } } diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 290976867d..a912f34f20 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -168,7 +168,10 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Tmpl, Decl *New, LateInstantiatedAttrVec *LateAttrs, LocalInstantiationScope *OuterMostScope) { - for (auto TmplAttr : Tmpl->attrs()) { + for (AttrVec::const_iterator i = Tmpl->attr_begin(), e = Tmpl->attr_end(); + i != e; ++i) { + const Attr *TmplAttr = *i; + // FIXME: This should be generalized to more than just the AlignedAttr. const AlignedAttr *Aligned = dyn_cast(TmplAttr); if (Aligned && Aligned->isAlignmentDependent()) { diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 9856307844..1c24e6b7b2 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1675,8 +1675,9 @@ bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) { } bool CursorVisitor::VisitAttributes(Decl *D) { - for (auto I : D->attrs()) - if (Visit(MakeCXCursor(I, D, TU))) + for (AttrVec::const_iterator i = D->attr_begin(), e = D->attr_end(); + i != e; ++i) + if (Visit(MakeCXCursor(*i, D, TU))) return true; return false; @@ -6040,8 +6041,9 @@ static int getCursorPlatformAvailabilityForDecl(const Decl *D, int availability_size) { bool HadAvailAttr = false; int N = 0; - for (auto A : D->attrs()) { - if (DeprecatedAttr *Deprecated = dyn_cast(A)) { + for (Decl::attr_iterator A = D->attr_begin(), AEnd = D->attr_end(); A != AEnd; + ++A) { + if (DeprecatedAttr *Deprecated = dyn_cast(*A)) { HadAvailAttr = true; if (always_deprecated) *always_deprecated = 1; @@ -6050,7 +6052,7 @@ static int getCursorPlatformAvailabilityForDecl(const Decl *D, continue; } - if (UnavailableAttr *Unavailable = dyn_cast(A)) { + if (UnavailableAttr *Unavailable = dyn_cast(*A)) { HadAvailAttr = true; if (always_unavailable) *always_unavailable = 1; @@ -6060,7 +6062,7 @@ static int getCursorPlatformAvailabilityForDecl(const Decl *D, continue; } - if (AvailabilityAttr *Avail = dyn_cast(A)) { + if (AvailabilityAttr *Avail = dyn_cast(*A)) { HadAvailAttr = true; if (N < availability_size) { availability[N].Platform diff --git a/tools/libclang/IndexingContext.cpp b/tools/libclang/IndexingContext.cpp index c5f20e0b38..2e0f7c20fc 100644 --- a/tools/libclang/IndexingContext.cpp +++ b/tools/libclang/IndexingContext.cpp @@ -67,7 +67,9 @@ AttrListInfo::AttrListInfo(const Decl *D, IndexingContext &IdxCtx) if (!D->hasAttrs()) return; - for (auto A : D->attrs()) { + for (AttrVec::const_iterator AttrI = D->attr_begin(), AttrE = D->attr_end(); + AttrI != AttrE; ++AttrI) { + const Attr *A = *AttrI; CXCursor C = MakeCXCursor(A, D, IdxCtx.CXTU); CXIdxLoc Loc = IdxCtx.getIndexLoc(A->getLocation()); switch (C.kind) {