diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2014-03-07 19:56:05 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2014-03-07 19:56:05 +0000 |
| commit | 629afaefe0cd1a583ccee54918b7b13f48bfe273 (patch) | |
| tree | 9a236cdf36b4b96c8aad05ccdb63d8f40f9acd9c /clang/lib/CodeGen | |
| parent | d72a5f103da45e5abe10497308fce5aeb992cdc2 (diff) | |
| download | bcm5719-llvm-629afaefe0cd1a583ccee54918b7b13f48bfe273.tar.gz bcm5719-llvm-629afaefe0cd1a583ccee54918b7b13f48bfe273.zip | |
[C++11] Replacing DeclBase iterators decls_begin() and decls_end() with iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203278
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 15 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 14 | ||||
| -rw-r--r-- | clang/lib/CodeGen/ModuleBuilder.cpp | 6 |
3 files changed, 14 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 761876988ac..d115f264ba7 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -935,9 +935,8 @@ void CGDebugInfo::CollectRecordFields(const RecordDecl *record, // Static and non-static members should appear in the same order as // the corresponding declarations in the source program. - for (RecordDecl::decl_iterator I = record->decls_begin(), - E = record->decls_end(); I != E; ++I) - if (const VarDecl *V = dyn_cast<VarDecl>(*I)) { + for (const auto *I : record->decls()) + if (const auto *V = dyn_cast<VarDecl>(I)) { // Reuse the existing static member declaration if one exists llvm::DenseMap<const Decl *, llvm::WeakVH>::iterator MI = StaticDataMemberCache.find(V->getCanonicalDecl()); @@ -948,7 +947,7 @@ void CGDebugInfo::CollectRecordFields(const RecordDecl *record, llvm::DIDerivedType(cast<llvm::MDNode>(MI->second))); } else elements.push_back(CreateRecordStaticField(V, RecordTy)); - } else if (FieldDecl *field = dyn_cast<FieldDecl>(*I)) { + } else if (const auto *field = dyn_cast<FieldDecl>(I)) { CollectRecordNormalField(field, layout.getFieldOffset(fieldNo), tunit, elements, RecordTy); @@ -1130,9 +1129,8 @@ CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit, // Since we want more than just the individual member decls if we // have templated functions iterate over every declaration to gather // the functions. - for(DeclContext::decl_iterator I = RD->decls_begin(), - E = RD->decls_end(); I != E; ++I) { - if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*I)) { + for(const auto *I : RD->decls()) { + if (const auto *Method = dyn_cast<CXXMethodDecl>(I)) { // Reuse the existing member function declaration if it exists. // It may be associated with the declaration of the type & should be // reused as we're building the definition. @@ -1149,8 +1147,7 @@ CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit, EltTys.push_back(CreateCXXMemberFunction(Method, Unit, RecordTy)); } else EltTys.push_back(MI->second); - } else if (const FunctionTemplateDecl *FTD = - dyn_cast<FunctionTemplateDecl>(*I)) { + } else if (const auto *FTD = dyn_cast<FunctionTemplateDecl>(I)) { // Add any template specializations that have already been seen. Like // implicit member functions, these may have been added to a declaration // in the case of vtable-based debug info reduction. diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 9b3e32952e1..a5cd9e34af5 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2832,13 +2832,12 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) { /// EmitNamespace - Emit all declarations in a namespace. void CodeGenModule::EmitNamespace(const NamespaceDecl *ND) { - for (RecordDecl::decl_iterator I = ND->decls_begin(), E = ND->decls_end(); - I != E; ++I) { - if (const VarDecl *VD = dyn_cast<VarDecl>(*I)) + for (auto *I : ND->decls()) { + if (const auto *VD = dyn_cast<VarDecl>(I)) if (VD->getTemplateSpecializationKind() != TSK_ExplicitSpecialization && VD->getTemplateSpecializationKind() != TSK_Undeclared) continue; - EmitTopLevelDecl(*I); + EmitTopLevelDecl(I); } } @@ -2850,17 +2849,16 @@ void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) { return; } - for (RecordDecl::decl_iterator I = LSD->decls_begin(), E = LSD->decls_end(); - I != E; ++I) { + for (auto *I : LSD->decls()) { // Meta-data for ObjC class includes references to implemented methods. // Generate class's method definitions first. - if (ObjCImplDecl *OID = dyn_cast<ObjCImplDecl>(*I)) { + if (auto *OID = dyn_cast<ObjCImplDecl>(I)) { for (ObjCContainerDecl::method_iterator M = OID->meth_begin(), MEnd = OID->meth_end(); M != MEnd; ++M) EmitTopLevelDecl(*M); } - EmitTopLevelDecl(*I); + EmitTopLevelDecl(I); } } diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp index a51abf03d5c..d54a4a8186f 100644 --- a/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/clang/lib/CodeGen/ModuleBuilder.cpp @@ -93,10 +93,8 @@ namespace { // In C++, we may have member functions that need to be emitted at this // point. if (Ctx->getLangOpts().CPlusPlus && !D->isDependentContext()) { - for (DeclContext::decl_iterator M = D->decls_begin(), - MEnd = D->decls_end(); - M != MEnd; ++M) - if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(*M)) + for (auto *M : D->decls()) + if (auto *Method = dyn_cast<CXXMethodDecl>(M)) if (Method->doesThisDeclarationHaveABody() && (Method->hasAttr<UsedAttr>() || Method->hasAttr<ConstructorAttr>())) |

