diff options
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 20 | ||||
| -rw-r--r-- | clang/lib/AST/Decl.cpp | 69 | ||||
| -rw-r--r-- | clang/lib/AST/DeclBase.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/AST/ExprCXX.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/AST/Type.cpp | 6 |
6 files changed, 44 insertions, 67 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b1f31c429ed..d94fa4ba36f 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -332,11 +332,9 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl( // Search for comments attached to declarations in the redeclaration chain. const RawComment *RC = NULL; const Decl *OriginalDeclForRC = NULL; - for (Decl::redecl_iterator I = D->redecls_begin(), - E = D->redecls_end(); - I != E; ++I) { + for (auto I : D->redecls()) { llvm::DenseMap<const Decl *, RawCommentAndCacheFlags>::iterator Pos = - RedeclComments.find(*I); + RedeclComments.find(I); if (Pos != RedeclComments.end()) { const RawCommentAndCacheFlags &Raw = Pos->second; if (Raw.getKind() != RawCommentAndCacheFlags::NoCommentInDecl) { @@ -345,16 +343,16 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl( break; } } else { - RC = getRawCommentForDeclNoCache(*I); - OriginalDeclForRC = *I; + RC = getRawCommentForDeclNoCache(I); + OriginalDeclForRC = I; RawCommentAndCacheFlags Raw; if (RC) { Raw.setRaw(RC); Raw.setKind(RawCommentAndCacheFlags::FromDecl); } else Raw.setKind(RawCommentAndCacheFlags::NoCommentInDecl); - Raw.setOriginalDecl(*I); - RedeclComments[*I] = Raw; + Raw.setOriginalDecl(I); + RedeclComments[I] = Raw; if (RC) break; } @@ -372,10 +370,8 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl( Raw.setKind(RawCommentAndCacheFlags::FromRedecl); Raw.setOriginalDecl(OriginalDeclForRC); - for (Decl::redecl_iterator I = D->redecls_begin(), - E = D->redecls_end(); - I != E; ++I) { - RawCommentAndCacheFlags &R = RedeclComments[*I]; + for (auto I : D->redecls()) { + RawCommentAndCacheFlags &R = RedeclComments[I]; if (R.getKind() == RawCommentAndCacheFlags::NoCommentInDecl) R = Raw; } diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index db404ec5fe3..6eaf1405501 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1245,10 +1245,8 @@ public: // that all other computed linkages match, check that the one we just // computed also does. NamedDecl *Old = NULL; - for (NamedDecl::redecl_iterator I = D->redecls_begin(), - E = D->redecls_end(); - I != E; ++I) { - NamedDecl *T = cast<NamedDecl>(*I); + for (auto I : D->redecls()) { + NamedDecl *T = cast<NamedDecl>(I); if (T == D) continue; if (!T->isInvalidDecl() && T->hasCachedLinkage()) { @@ -1793,23 +1791,21 @@ VarDecl *VarDecl::getActingDefinition() { VarDecl *LastTentative = 0; VarDecl *First = getFirstDecl(); - for (redecl_iterator I = First->redecls_begin(), E = First->redecls_end(); - I != E; ++I) { - Kind = (*I)->isThisDeclarationADefinition(); + for (auto I : First->redecls()) { + Kind = I->isThisDeclarationADefinition(); if (Kind == Definition) return 0; else if (Kind == TentativeDefinition) - LastTentative = *I; + LastTentative = I; } return LastTentative; } VarDecl *VarDecl::getDefinition(ASTContext &C) { VarDecl *First = getFirstDecl(); - for (redecl_iterator I = First->redecls_begin(), E = First->redecls_end(); - I != E; ++I) { - if ((*I)->isThisDeclarationADefinition(C) == Definition) - return *I; + for (auto I : First->redecls()) { + if (I->isThisDeclarationADefinition(C) == Definition) + return I; } return 0; } @@ -1818,9 +1814,8 @@ VarDecl::DefinitionKind VarDecl::hasDefinition(ASTContext &C) const { DefinitionKind Kind = DeclarationOnly; const VarDecl *First = getFirstDecl(); - for (redecl_iterator I = First->redecls_begin(), E = First->redecls_end(); - I != E; ++I) { - Kind = std::max(Kind, (*I)->isThisDeclarationADefinition(C)); + for (auto I : First->redecls()) { + Kind = std::max(Kind, I->isThisDeclarationADefinition(C)); if (Kind == Definition) break; } @@ -1829,13 +1824,11 @@ VarDecl::DefinitionKind VarDecl::hasDefinition(ASTContext &C) const { } const Expr *VarDecl::getAnyInitializer(const VarDecl *&D) const { - redecl_iterator I = redecls_begin(), E = redecls_end(); - while (I != E && !I->getInit()) - ++I; - - if (I != E) { - D = *I; - return I->getInit(); + for (auto I : redecls()) { + if (auto Expr = I->getInit()) { + D = I; + return Expr; + } } return 0; } @@ -1860,10 +1853,9 @@ VarDecl *VarDecl::getOutOfLineDefinition() { if (!isStaticDataMember()) return 0; - for (VarDecl::redecl_iterator RD = redecls_begin(), RDEnd = redecls_end(); - RD != RDEnd; ++RD) { + for (auto RD : redecls()) { if (RD->getLexicalDeclContext()->isFileContext()) - return *RD; + return RD; } return 0; @@ -2190,9 +2182,9 @@ bool FunctionDecl::isVariadic() const { } bool FunctionDecl::hasBody(const FunctionDecl *&Definition) const { - for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) { + for (auto I : redecls()) { if (I->Body || I->IsLateTemplateParsed) { - Definition = *I; + Definition = I; return true; } } @@ -2215,10 +2207,10 @@ bool FunctionDecl::hasTrivialBody() const } bool FunctionDecl::isDefined(const FunctionDecl *&Definition) const { - for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) { + for (auto I : redecls()) { if (I->IsDeleted || I->IsDefaulted || I->Body || I->IsLateTemplateParsed || I->hasAttr<AliasAttr>()) { - Definition = I->IsDeleted ? I->getCanonicalDecl() : *I; + Definition = I->IsDeleted ? I->getCanonicalDecl() : I; return true; } } @@ -2680,9 +2672,7 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const { // If any declaration is 'inline' but not 'extern', then this definition // is externally visible. - for (redecl_iterator Redecl = redecls_begin(), RedeclEnd = redecls_end(); - Redecl != RedeclEnd; - ++Redecl) { + for (auto Redecl : redecls()) { if (Redecl->isInlineSpecified() && Redecl->getStorageClass() != SC_Extern) return true; @@ -2699,10 +2689,8 @@ bool FunctionDecl::isInlineDefinitionExternallyVisible() const { // [...] If all of the file scope declarations for a function in a // translation unit include the inline function specifier without extern, // then the definition in that translation unit is an inline definition. - for (redecl_iterator Redecl = redecls_begin(), RedeclEnd = redecls_end(); - Redecl != RedeclEnd; - ++Redecl) { - if (RedeclForcesDefC99(*Redecl)) + for (auto Redecl : redecls()) { + if (RedeclForcesDefC99(Redecl)) return true; } @@ -3187,8 +3175,8 @@ void TagDecl::startDefinition() { if (CXXRecordDecl *D = dyn_cast<CXXRecordDecl>(this)) { struct CXXRecordDecl::DefinitionData *Data = new (getASTContext()) struct CXXRecordDecl::DefinitionData(D); - for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) - cast<CXXRecordDecl>(*I)->DefinitionData = Data; + for (auto I : redecls()) + cast<CXXRecordDecl>(I)->DefinitionData = Data; } } @@ -3220,10 +3208,9 @@ TagDecl *TagDecl::getDefinition() const { if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(this)) return CXXRD->getDefinition(); - for (redecl_iterator R = redecls_begin(), REnd = redecls_end(); - R != REnd; ++R) + for (auto R : redecls()) if (R->isCompleteDefinition()) - return *R; + return R; return 0; } diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 2ca491194dd..00692df46c5 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -313,7 +313,7 @@ bool Decl::isReferenced() const { return true; // Check redeclarations. - for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) + for (auto I : redecls()) if (I->Referenced) return true; diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 94c4d5187a3..b76fc5cf38a 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -465,9 +465,8 @@ void ObjCInterfaceDecl::startDefinition() { allocateDefinitionData(); // Update all of the declarations with a pointer to the definition. - for (redecl_iterator RD = redecls_begin(), RDEnd = redecls_end(); - RD != RDEnd; ++RD) { - if (*RD != this) + for (auto RD : redecls()) { + if (RD != this) RD->Data = Data; } } @@ -1591,8 +1590,7 @@ void ObjCProtocolDecl::startDefinition() { allocateDefinitionData(); // Update all of the declarations with a pointer to the definition. - for (redecl_iterator RD = redecls_begin(), RDEnd = redecls_end(); - RD != RDEnd; ++RD) + for (auto RD : redecls()) RD->Data = this->Data; } diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp index 516b60d89bc..ee4992590a2 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -108,10 +108,8 @@ UuidAttr *CXXUuidofExpr::GetUuidAttrOfType(QualType QT, return UuidForRD; } - for (CXXRecordDecl::redecl_iterator I = RD->redecls_begin(), - E = RD->redecls_end(); - I != E; ++I) - if (UuidAttr *Uuid = I->getAttr<UuidAttr>()) + for (auto I : RD->redecls()) + if (auto Uuid = I->getAttr<UuidAttr>()) return Uuid; return 0; diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index cebdbad4fc9..6fb1172a899 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1849,11 +1849,9 @@ TagType::TagType(TypeClass TC, const TagDecl *D, QualType can) decl(const_cast<TagDecl*>(D)) {} static TagDecl *getInterestingTagDecl(TagDecl *decl) { - for (TagDecl::redecl_iterator I = decl->redecls_begin(), - E = decl->redecls_end(); - I != E; ++I) { + for (auto I : decl->redecls()) { if (I->isCompleteDefinition() || I->isBeingDefined()) - return *I; + return I; } // If there's no definition (not even in progress), return what we have. return decl; |

