forked from OSchip/llvm-project
[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
This commit is contained in:
parent
d72a5f103d
commit
629afaefe0
|
@ -1222,13 +1222,11 @@ bool DataRecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC
|
|||
if (!DC)
|
||||
return true;
|
||||
|
||||
for (DeclContext::decl_iterator Child = DC->decls_begin(),
|
||||
ChildEnd = DC->decls_end();
|
||||
Child != ChildEnd; ++Child) {
|
||||
for (auto *Child : DC->decls()) {
|
||||
// BlockDecls and CapturedDecls are traversed through BlockExprs and
|
||||
// CapturedStmts respectively.
|
||||
if (!isa<BlockDecl>(*Child) && !isa<CapturedDecl>(*Child))
|
||||
TRY_TO(TraverseDecl(*Child));
|
||||
if (!isa<BlockDecl>(Child) && !isa<CapturedDecl>(Child))
|
||||
TRY_TO(TraverseDecl(Child));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1306,17 +1306,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
typedef llvm::iterator_range<decl_iterator> decl_range;
|
||||
|
||||
/// decls_begin/decls_end - Iterate over the declarations stored in
|
||||
/// this context.
|
||||
decl_iterator decls_begin() const;
|
||||
decl_iterator decls_end() const { return decl_iterator(); }
|
||||
decl_range decls() const;
|
||||
decl_iterator decls_begin() const { return decls().begin(); }
|
||||
decl_iterator decls_end() const { return decls().end(); }
|
||||
bool decls_empty() const;
|
||||
|
||||
/// noload_decls_begin/end - Iterate over the declarations stored in this
|
||||
/// context that are currently loaded; don't attempt to retrieve anything
|
||||
/// from an external source.
|
||||
decl_iterator noload_decls_begin() const;
|
||||
decl_iterator noload_decls_end() const { return decl_iterator(); }
|
||||
decl_range noload_decls() const;
|
||||
decl_iterator noload_decls_begin() const { return noload_decls().begin(); }
|
||||
decl_iterator noload_decls_end() const { return noload_decls().end(); }
|
||||
|
||||
/// specific_decl_iterator - Iterates over a subrange of
|
||||
/// declarations stored in a DeclContext, providing only those that
|
||||
|
|
|
@ -1303,13 +1303,11 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) {
|
|||
if (!DC)
|
||||
return true;
|
||||
|
||||
for (DeclContext::decl_iterator Child = DC->decls_begin(),
|
||||
ChildEnd = DC->decls_end();
|
||||
Child != ChildEnd; ++Child) {
|
||||
for (auto *Child : DC->decls()) {
|
||||
// BlockDecls and CapturedDecls are traversed through BlockExprs and
|
||||
// CapturedStmts respectively.
|
||||
if (!isa<BlockDecl>(*Child) && !isa<CapturedDecl>(*Child))
|
||||
TRY_TO(TraverseDecl(*Child));
|
||||
if (!isa<BlockDecl>(Child) && !isa<CapturedDecl>(Child))
|
||||
TRY_TO(TraverseDecl(Child));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -930,10 +930,8 @@ static Optional<unsigned> findAnonymousStructOrUnionIndex(RecordDecl *Anon) {
|
|||
return None;
|
||||
|
||||
unsigned Index = 0;
|
||||
for (DeclContext::decl_iterator D = Owner->noload_decls_begin(),
|
||||
DEnd = Owner->noload_decls_end();
|
||||
D != DEnd; ++D) {
|
||||
FieldDecl *F = dyn_cast<FieldDecl>(*D);
|
||||
for (const auto *D : Owner->noload_decls()) {
|
||||
const auto *F = dyn_cast<FieldDecl>(D);
|
||||
if (!F || !F->isAnonymousStructOrUnion())
|
||||
continue;
|
||||
|
||||
|
@ -1908,11 +1906,8 @@ void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
|
|||
return;
|
||||
}
|
||||
|
||||
for (DeclContext::decl_iterator From = FromDC->decls_begin(),
|
||||
FromEnd = FromDC->decls_end();
|
||||
From != FromEnd;
|
||||
++From)
|
||||
Importer.Import(*From);
|
||||
for (auto *From : FromDC->decls())
|
||||
Importer.Import(From);
|
||||
}
|
||||
|
||||
bool ASTNodeImporter::ImportDefinition(RecordDecl *From, RecordDecl *To,
|
||||
|
@ -2852,10 +2847,8 @@ static unsigned getFieldIndex(Decl *F) {
|
|||
return 0;
|
||||
|
||||
unsigned Index = 1;
|
||||
for (DeclContext::decl_iterator D = Owner->noload_decls_begin(),
|
||||
DEnd = Owner->noload_decls_end();
|
||||
D != DEnd; ++D) {
|
||||
if (*D == F)
|
||||
for (const auto *D : Owner->noload_decls()) {
|
||||
if (D == F)
|
||||
return Index;
|
||||
|
||||
if (isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D))
|
||||
|
|
|
@ -1076,15 +1076,14 @@ ExternalASTSource::SetExternalVisibleDeclsForName(const DeclContext *DC,
|
|||
return List.getLookupResult();
|
||||
}
|
||||
|
||||
DeclContext::decl_iterator DeclContext::noload_decls_begin() const {
|
||||
return decl_iterator(FirstDecl);
|
||||
DeclContext::decl_range DeclContext::noload_decls() const {
|
||||
return decl_range(decl_iterator(FirstDecl), decl_iterator());
|
||||
}
|
||||
|
||||
DeclContext::decl_iterator DeclContext::decls_begin() const {
|
||||
DeclContext::decl_range DeclContext::decls() const {
|
||||
if (hasExternalLexicalStorage())
|
||||
LoadLexicalDeclsFromExternalStorage();
|
||||
|
||||
return decl_iterator(FirstDecl);
|
||||
return decl_range(decl_iterator(FirstDecl), decl_iterator());
|
||||
}
|
||||
|
||||
bool DeclContext::decls_empty() const {
|
||||
|
|
|
@ -95,9 +95,8 @@ void CallGraph::addNodesForBlocks(DeclContext *D) {
|
|||
if (BlockDecl *BD = dyn_cast<BlockDecl>(D))
|
||||
addNodeForDecl(BD, true);
|
||||
|
||||
for (DeclContext::decl_iterator I = D->decls_begin(), E = D->decls_end();
|
||||
I!=E; ++I)
|
||||
if (DeclContext *DC = dyn_cast<DeclContext>(*I))
|
||||
for (auto *I : D->decls())
|
||||
if (auto *DC = dyn_cast<DeclContext>(I))
|
||||
addNodesForBlocks(DC);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>()))
|
||||
|
|
|
@ -368,8 +368,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
|
|||
Out << "\n";
|
||||
|
||||
// Print decls in the DeclContext.
|
||||
for (DeclContext::decl_iterator I = DC->decls_begin(), E = DC->decls_end();
|
||||
I != E; ++I) {
|
||||
for (auto *I : DC->decls()) {
|
||||
for (unsigned i = 0; i < Indentation; ++i)
|
||||
Out << " ";
|
||||
|
||||
|
@ -393,58 +392,58 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
|
|||
case Decl::CXXDestructor:
|
||||
case Decl::CXXConversion:
|
||||
{
|
||||
DeclContext* DC = cast<DeclContext>(*I);
|
||||
DeclContext* DC = cast<DeclContext>(I);
|
||||
PrintDeclContext(DC, Indentation+2);
|
||||
break;
|
||||
}
|
||||
case Decl::IndirectField: {
|
||||
IndirectFieldDecl* IFD = cast<IndirectFieldDecl>(*I);
|
||||
IndirectFieldDecl* IFD = cast<IndirectFieldDecl>(I);
|
||||
Out << "<IndirectField> " << *IFD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::Label: {
|
||||
LabelDecl *LD = cast<LabelDecl>(*I);
|
||||
LabelDecl *LD = cast<LabelDecl>(I);
|
||||
Out << "<Label> " << *LD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::Field: {
|
||||
FieldDecl *FD = cast<FieldDecl>(*I);
|
||||
FieldDecl *FD = cast<FieldDecl>(I);
|
||||
Out << "<field> " << *FD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::Typedef:
|
||||
case Decl::TypeAlias: {
|
||||
TypedefNameDecl* TD = cast<TypedefNameDecl>(*I);
|
||||
TypedefNameDecl* TD = cast<TypedefNameDecl>(I);
|
||||
Out << "<typedef> " << *TD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::EnumConstant: {
|
||||
EnumConstantDecl* ECD = cast<EnumConstantDecl>(*I);
|
||||
EnumConstantDecl* ECD = cast<EnumConstantDecl>(I);
|
||||
Out << "<enum constant> " << *ECD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::Var: {
|
||||
VarDecl* VD = cast<VarDecl>(*I);
|
||||
VarDecl* VD = cast<VarDecl>(I);
|
||||
Out << "<var> " << *VD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::ImplicitParam: {
|
||||
ImplicitParamDecl* IPD = cast<ImplicitParamDecl>(*I);
|
||||
ImplicitParamDecl* IPD = cast<ImplicitParamDecl>(I);
|
||||
Out << "<implicit parameter> " << *IPD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::ParmVar: {
|
||||
ParmVarDecl* PVD = cast<ParmVarDecl>(*I);
|
||||
ParmVarDecl* PVD = cast<ParmVarDecl>(I);
|
||||
Out << "<parameter> " << *PVD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::ObjCProperty: {
|
||||
ObjCPropertyDecl* OPD = cast<ObjCPropertyDecl>(*I);
|
||||
ObjCPropertyDecl* OPD = cast<ObjCPropertyDecl>(I);
|
||||
Out << "<objc property> " << *OPD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::FunctionTemplate: {
|
||||
FunctionTemplateDecl* FTD = cast<FunctionTemplateDecl>(*I);
|
||||
FunctionTemplateDecl* FTD = cast<FunctionTemplateDecl>(I);
|
||||
Out << "<function template> " << *FTD << '\n';
|
||||
break;
|
||||
}
|
||||
|
@ -457,21 +456,21 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
|
|||
break;
|
||||
}
|
||||
case Decl::NamespaceAlias: {
|
||||
NamespaceAliasDecl* NAD = cast<NamespaceAliasDecl>(*I);
|
||||
NamespaceAliasDecl* NAD = cast<NamespaceAliasDecl>(I);
|
||||
Out << "<namespace alias> " << *NAD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::ClassTemplate: {
|
||||
ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(*I);
|
||||
ClassTemplateDecl *CTD = cast<ClassTemplateDecl>(I);
|
||||
Out << "<class template> " << *CTD << '\n';
|
||||
break;
|
||||
}
|
||||
case Decl::OMPThreadPrivate: {
|
||||
Out << "<omp threadprivate> " << '"' << *I << "\"\n";
|
||||
Out << "<omp threadprivate> " << '"' << I << "\"\n";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Out << "DeclKind: " << DK << '"' << *I << "\"\n";
|
||||
Out << "DeclKind: " << DK << '"' << I << "\"\n";
|
||||
llvm_unreachable("decl unhandled");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,16 +57,14 @@ void ASTMergeAction::ExecuteAction() {
|
|||
/*MinimalImport=*/false);
|
||||
|
||||
TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
|
||||
for (DeclContext::decl_iterator D = TU->decls_begin(),
|
||||
DEnd = TU->decls_end();
|
||||
D != DEnd; ++D) {
|
||||
for (auto *D : TU->decls()) {
|
||||
// Don't re-import __va_list_tag, __builtin_va_list.
|
||||
if (NamedDecl *ND = dyn_cast<NamedDecl>(*D))
|
||||
if (const auto *ND = dyn_cast<NamedDecl>(D))
|
||||
if (IdentifierInfo *II = ND->getIdentifier())
|
||||
if (II->isStr("__va_list_tag") || II->isStr("__builtin_va_list"))
|
||||
continue;
|
||||
|
||||
Importer.Import(*D);
|
||||
Importer.Import(D);
|
||||
}
|
||||
|
||||
delete Unit;
|
||||
|
|
|
@ -873,9 +873,8 @@ public:
|
|||
void handleFileLevelDecl(Decl *D) {
|
||||
Unit.addFileLevelDecl(D);
|
||||
if (NamespaceDecl *NSD = dyn_cast<NamespaceDecl>(D)) {
|
||||
for (NamespaceDecl::decl_iterator
|
||||
I = NSD->decls_begin(), E = NSD->decls_end(); I != E; ++I)
|
||||
handleFileLevelDecl(*I);
|
||||
for (auto *I : NSD->decls())
|
||||
handleFileLevelDecl(I);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1138,11 +1138,9 @@ static void diagnoseBadDirectAccess(Sema &S,
|
|||
// Check whether there's an AccessSpecDecl preceding this in the
|
||||
// chain of the DeclContext.
|
||||
bool isImplicit = true;
|
||||
for (CXXRecordDecl::decl_iterator
|
||||
I = DeclaringClass->decls_begin(), E = DeclaringClass->decls_end();
|
||||
I != E; ++I) {
|
||||
if (*I == ImmediateChild) break;
|
||||
if (isa<AccessSpecDecl>(*I)) {
|
||||
for (const auto *I : DeclaringClass->decls()) {
|
||||
if (I == ImmediateChild) break;
|
||||
if (isa<AccessSpecDecl>(I)) {
|
||||
isImplicit = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -5731,11 +5731,9 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext,
|
|||
ResultBuilder &Results) {
|
||||
typedef CodeCompletionResult Result;
|
||||
|
||||
for (DeclContext::decl_iterator D = Ctx->decls_begin(),
|
||||
DEnd = Ctx->decls_end();
|
||||
D != DEnd; ++D) {
|
||||
for (const auto *D : Ctx->decls()) {
|
||||
// Record any protocols we find.
|
||||
if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(*D))
|
||||
if (const auto *Proto = dyn_cast<ObjCProtocolDecl>(D))
|
||||
if (!OnlyForwardDeclarations || !Proto->hasDefinition())
|
||||
Results.AddResult(Result(Proto, Results.getBasePriority(Proto), 0),
|
||||
CurContext, 0, false);
|
||||
|
@ -5799,11 +5797,9 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext,
|
|||
ResultBuilder &Results) {
|
||||
typedef CodeCompletionResult Result;
|
||||
|
||||
for (DeclContext::decl_iterator D = Ctx->decls_begin(),
|
||||
DEnd = Ctx->decls_end();
|
||||
D != DEnd; ++D) {
|
||||
for (const auto *D : Ctx->decls()) {
|
||||
// Record any interfaces we find.
|
||||
if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(*D))
|
||||
if (const auto *Class = dyn_cast<ObjCInterfaceDecl>(D))
|
||||
if ((!OnlyForwardDeclarations || !Class->hasDefinition()) &&
|
||||
(!OnlyUnimplemented || !Class->getImplementation()))
|
||||
Results.AddResult(Result(Class, Results.getBasePriority(Class), 0),
|
||||
|
@ -5901,10 +5897,8 @@ void Sema::CodeCompleteObjCInterfaceCategory(Scope *S,
|
|||
// Add all of the categories we know about.
|
||||
Results.EnterNewScope();
|
||||
TranslationUnitDecl *TU = Context.getTranslationUnitDecl();
|
||||
for (DeclContext::decl_iterator D = TU->decls_begin(),
|
||||
DEnd = TU->decls_end();
|
||||
D != DEnd; ++D)
|
||||
if (ObjCCategoryDecl *Category = dyn_cast<ObjCCategoryDecl>(*D))
|
||||
for (const auto *D : TU->decls())
|
||||
if (const auto *Category = dyn_cast<ObjCCategoryDecl>(D))
|
||||
if (CategoryNames.insert(Category->getIdentifier()))
|
||||
Results.AddResult(Result(Category, Results.getBasePriority(Category),0),
|
||||
CurContext, 0, false);
|
||||
|
@ -5975,10 +5969,8 @@ void Sema::CodeCompleteObjCPropertyDefinition(Scope *S) {
|
|||
|
||||
// Ignore any properties that have already been implemented.
|
||||
Container = getContainerDef(Container);
|
||||
for (DeclContext::decl_iterator D = Container->decls_begin(),
|
||||
DEnd = Container->decls_end();
|
||||
D != DEnd; ++D)
|
||||
if (ObjCPropertyImplDecl *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(*D))
|
||||
for (const auto *D : Container->decls())
|
||||
if (const auto *PropertyImpl = dyn_cast<ObjCPropertyImplDecl>(D))
|
||||
Results.Ignore(PropertyImpl->getPropertyDecl());
|
||||
|
||||
// Add any properties that we find.
|
||||
|
|
|
@ -3466,12 +3466,10 @@ static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S,
|
|||
bool Invalid = false;
|
||||
|
||||
// Look every FieldDecl and IndirectFieldDecl with a name.
|
||||
for (RecordDecl::decl_iterator D = AnonRecord->decls_begin(),
|
||||
DEnd = AnonRecord->decls_end();
|
||||
D != DEnd; ++D) {
|
||||
if ((isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D)) &&
|
||||
cast<NamedDecl>(*D)->getDeclName()) {
|
||||
ValueDecl *VD = cast<ValueDecl>(*D);
|
||||
for (auto *D : AnonRecord->decls()) {
|
||||
if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
|
||||
cast<NamedDecl>(D)->getDeclName()) {
|
||||
ValueDecl *VD = cast<ValueDecl>(D);
|
||||
if (CheckAnonMemberRedeclaration(SemaRef, S, Owner, VD->getDeclName(),
|
||||
VD->getLocation(), diagKind)) {
|
||||
// C++ [class.union]p2:
|
||||
|
@ -3546,11 +3544,9 @@ StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS) {
|
|||
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record) {
|
||||
assert(Record->hasInClassInitializer());
|
||||
|
||||
for (DeclContext::decl_iterator I = Record->decls_begin(),
|
||||
E = Record->decls_end();
|
||||
I != E; ++I) {
|
||||
FieldDecl *FD = dyn_cast<FieldDecl>(*I);
|
||||
if (IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(*I))
|
||||
for (const auto *I : Record->decls()) {
|
||||
const auto *FD = dyn_cast<FieldDecl>(I);
|
||||
if (const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
|
||||
FD = IFD->getAnonField();
|
||||
if (FD && FD->hasInClassInitializer())
|
||||
return FD->getLocation();
|
||||
|
@ -3660,10 +3656,8 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
|||
// The member-specification of an anonymous union shall only
|
||||
// define non-static data members. [Note: nested types and
|
||||
// functions cannot be declared within an anonymous union. ]
|
||||
for (DeclContext::decl_iterator Mem = Record->decls_begin(),
|
||||
MemEnd = Record->decls_end();
|
||||
Mem != MemEnd; ++Mem) {
|
||||
if (FieldDecl *FD = dyn_cast<FieldDecl>(*Mem)) {
|
||||
for (auto *Mem : Record->decls()) {
|
||||
if (auto *FD = dyn_cast<FieldDecl>(Mem)) {
|
||||
// C++ [class.union]p3:
|
||||
// An anonymous union shall not have private or protected
|
||||
// members (clause 11).
|
||||
|
@ -3681,14 +3675,14 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
|||
// array of such objects.
|
||||
if (CheckNontrivialField(FD))
|
||||
Invalid = true;
|
||||
} else if ((*Mem)->isImplicit()) {
|
||||
} else if (Mem->isImplicit()) {
|
||||
// Any implicit members are fine.
|
||||
} else if (isa<TagDecl>(*Mem) && (*Mem)->getDeclContext() != Record) {
|
||||
} else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
|
||||
// This is a type that showed up in an
|
||||
// elaborated-type-specifier inside the anonymous struct or
|
||||
// union, but which actually declares a type outside of the
|
||||
// anonymous struct or union. It's okay.
|
||||
} else if (RecordDecl *MemRecord = dyn_cast<RecordDecl>(*Mem)) {
|
||||
} else if (auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
|
||||
if (!MemRecord->isAnonymousStructOrUnion() &&
|
||||
MemRecord->getDeclName()) {
|
||||
// Visual C++ allows type definition in anonymous struct or union.
|
||||
|
@ -3709,26 +3703,26 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
|
|||
diag::ext_anonymous_record_with_anonymous_type)
|
||||
<< (int)Record->isUnion();
|
||||
}
|
||||
} else if (isa<AccessSpecDecl>(*Mem)) {
|
||||
} else if (isa<AccessSpecDecl>(Mem)) {
|
||||
// Any access specifier is fine.
|
||||
} else {
|
||||
// We have something that isn't a non-static data
|
||||
// member. Complain about it.
|
||||
unsigned DK = diag::err_anonymous_record_bad_member;
|
||||
if (isa<TypeDecl>(*Mem))
|
||||
if (isa<TypeDecl>(Mem))
|
||||
DK = diag::err_anonymous_record_with_type;
|
||||
else if (isa<FunctionDecl>(*Mem))
|
||||
else if (isa<FunctionDecl>(Mem))
|
||||
DK = diag::err_anonymous_record_with_function;
|
||||
else if (isa<VarDecl>(*Mem))
|
||||
else if (isa<VarDecl>(Mem))
|
||||
DK = diag::err_anonymous_record_with_static;
|
||||
|
||||
// Visual C++ allows type definition in anonymous struct or union.
|
||||
if (getLangOpts().MicrosoftExt &&
|
||||
DK == diag::err_anonymous_record_with_type)
|
||||
Diag((*Mem)->getLocation(), diag::ext_anonymous_record_with_type)
|
||||
Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
|
||||
<< (int)Record->isUnion();
|
||||
else {
|
||||
Diag((*Mem)->getLocation(), DK)
|
||||
Diag(Mem->getLocation(), DK)
|
||||
<< (int)Record->isUnion();
|
||||
Invalid = true;
|
||||
}
|
||||
|
@ -9620,9 +9614,8 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D) {
|
|||
// and reattach to the current context.
|
||||
if (D->getLexicalDeclContext() == Context.getTranslationUnitDecl()) {
|
||||
// Is the decl actually in the context?
|
||||
for (DeclContext::decl_iterator DI = Context.getTranslationUnitDecl()->decls_begin(),
|
||||
DE = Context.getTranslationUnitDecl()->decls_end(); DI != DE; ++DI) {
|
||||
if (*DI == D) {
|
||||
for (const auto *DI : Context.getTranslationUnitDecl()->decls()) {
|
||||
if (DI == D) {
|
||||
Context.getTranslationUnitDecl()->removeDecl(D);
|
||||
break;
|
||||
}
|
||||
|
@ -11880,9 +11873,8 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
|
|||
// members of anonymous structs and unions in the total.
|
||||
unsigned NumNamedMembers = 0;
|
||||
if (Record) {
|
||||
for (RecordDecl::decl_iterator i = Record->decls_begin(),
|
||||
e = Record->decls_end(); i != e; i++) {
|
||||
if (IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(*i))
|
||||
for (const auto *I : Record->decls()) {
|
||||
if (const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
|
||||
if (IFD->getDeclName())
|
||||
++NumNamedMembers;
|
||||
}
|
||||
|
|
|
@ -2319,11 +2319,10 @@ namespace {
|
|||
llvm::SmallPtrSet<ValueDecl*, 4> UninitializedFields;
|
||||
|
||||
// At the beginning, all fields are uninitialized.
|
||||
for (DeclContext::decl_iterator I = RD->decls_begin(), E = RD->decls_end();
|
||||
I != E; ++I) {
|
||||
if (FieldDecl *FD = dyn_cast<FieldDecl>(*I)) {
|
||||
for (auto *I : RD->decls()) {
|
||||
if (auto *FD = dyn_cast<FieldDecl>(I)) {
|
||||
UninitializedFields.insert(FD);
|
||||
} else if (IndirectFieldDecl *IFD = dyn_cast<IndirectFieldDecl>(*I)) {
|
||||
} else if (auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
|
||||
UninitializedFields.insert(IFD->getAnonField());
|
||||
}
|
||||
}
|
||||
|
@ -3645,10 +3644,8 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
|
|||
}
|
||||
|
||||
// Fields.
|
||||
for (DeclContext::decl_iterator Mem = ClassDecl->decls_begin(),
|
||||
MemEnd = ClassDecl->decls_end();
|
||||
Mem != MemEnd; ++Mem) {
|
||||
if (FieldDecl *F = dyn_cast<FieldDecl>(*Mem)) {
|
||||
for (auto *Mem : ClassDecl->decls()) {
|
||||
if (auto *F = dyn_cast<FieldDecl>(Mem)) {
|
||||
// C++ [class.bit]p2:
|
||||
// A declaration for a bit-field that omits the identifier declares an
|
||||
// unnamed bit-field. Unnamed bit-fields are not members and cannot be
|
||||
|
@ -3671,7 +3668,7 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors,
|
|||
if (Info.isImplicitCopyOrMove())
|
||||
continue;
|
||||
|
||||
if (IndirectFieldDecl *F = dyn_cast<IndirectFieldDecl>(*Mem)) {
|
||||
if (auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
|
||||
if (F->getType()->isIncompleteArrayType()) {
|
||||
assert(ClassDecl->hasFlexibleArrayMember() &&
|
||||
"Incomplete array type is not valid");
|
||||
|
@ -4337,9 +4334,7 @@ static void CheckAbstractClassUsage(AbstractUsageInfo &Info,
|
|||
/// Check for invalid uses of an abstract type within a class definition.
|
||||
static void CheckAbstractClassUsage(AbstractUsageInfo &Info,
|
||||
CXXRecordDecl *RD) {
|
||||
for (CXXRecordDecl::decl_iterator
|
||||
I = RD->decls_begin(), E = RD->decls_end(); I != E; ++I) {
|
||||
Decl *D = *I;
|
||||
for (auto *D : RD->decls()) {
|
||||
if (D->isImplicit()) continue;
|
||||
|
||||
// Methods and method templates.
|
||||
|
@ -6571,9 +6566,8 @@ static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc,
|
|||
NS->setInline(*IsInline);
|
||||
// Patch up the lookup table for the containing namespace. This isn't really
|
||||
// correct, but it's good enough for this particular case.
|
||||
for (DeclContext::decl_iterator I = PrevNS->decls_begin(),
|
||||
E = PrevNS->decls_end(); I != E; ++I)
|
||||
if (NamedDecl *ND = dyn_cast<NamedDecl>(*I))
|
||||
for (auto *I : PrevNS->decls())
|
||||
if (auto *ND = dyn_cast<NamedDecl>(I))
|
||||
PrevNS->getParent()->makeDeclVisibleInContext(ND);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2055,9 +2055,7 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
|
|||
LateInstantiatedAttrVec LateAttrs;
|
||||
Instantiator.enableLateAttributeInstantiation(&LateAttrs);
|
||||
|
||||
for (RecordDecl::decl_iterator Member = Pattern->decls_begin(),
|
||||
MemberEnd = Pattern->decls_end();
|
||||
Member != MemberEnd; ++Member) {
|
||||
for (auto *Member : Pattern->decls()) {
|
||||
// Don't instantiate members not belonging in this semantic context.
|
||||
// e.g. for:
|
||||
// @code
|
||||
|
@ -2067,19 +2065,19 @@ Sema::InstantiateClass(SourceLocation PointOfInstantiation,
|
|||
// @endcode
|
||||
// 'class B' has the template as lexical context but semantically it is
|
||||
// introduced in namespace scope.
|
||||
if ((*Member)->getDeclContext() != Pattern)
|
||||
if (Member->getDeclContext() != Pattern)
|
||||
continue;
|
||||
|
||||
if ((*Member)->isInvalidDecl()) {
|
||||
if (Member->isInvalidDecl()) {
|
||||
Instantiation->setInvalidDecl();
|
||||
continue;
|
||||
}
|
||||
|
||||
Decl *NewMember = Instantiator.Visit(*Member);
|
||||
Decl *NewMember = Instantiator.Visit(Member);
|
||||
if (NewMember) {
|
||||
if (FieldDecl *Field = dyn_cast<FieldDecl>(NewMember)) {
|
||||
Fields.push_back(Field);
|
||||
FieldDecl *OldField = cast<FieldDecl>(*Member);
|
||||
FieldDecl *OldField = cast<FieldDecl>(Member);
|
||||
if (OldField->getInClassInitializer())
|
||||
FieldsWithMemberInitializers.push_back(std::make_pair(OldField,
|
||||
Field));
|
||||
|
@ -2471,11 +2469,9 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
|||
TSK == TSK_ExplicitInstantiationDeclaration ||
|
||||
(TSK == TSK_ImplicitInstantiation && Instantiation->isLocalClass())) &&
|
||||
"Unexpected template specialization kind!");
|
||||
for (DeclContext::decl_iterator D = Instantiation->decls_begin(),
|
||||
DEnd = Instantiation->decls_end();
|
||||
D != DEnd; ++D) {
|
||||
for (auto *D : Instantiation->decls()) {
|
||||
bool SuppressNew = false;
|
||||
if (FunctionDecl *Function = dyn_cast<FunctionDecl>(*D)) {
|
||||
if (auto *Function = dyn_cast<FunctionDecl>(D)) {
|
||||
if (FunctionDecl *Pattern
|
||||
= Function->getInstantiatedFromMemberFunction()) {
|
||||
MemberSpecializationInfo *MSInfo
|
||||
|
@ -2516,7 +2512,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
|||
std::make_pair(Function, PointOfInstantiation));
|
||||
}
|
||||
}
|
||||
} else if (VarDecl *Var = dyn_cast<VarDecl>(*D)) {
|
||||
} else if (auto *Var = dyn_cast<VarDecl>(D)) {
|
||||
if (isa<VarTemplateSpecializationDecl>(Var))
|
||||
continue;
|
||||
|
||||
|
@ -2552,7 +2548,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
|||
Var->setTemplateSpecializationKind(TSK, PointOfInstantiation);
|
||||
}
|
||||
}
|
||||
} else if (CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(*D)) {
|
||||
} else if (auto *Record = dyn_cast<CXXRecordDecl>(D)) {
|
||||
// Always skip the injected-class-name, along with any
|
||||
// redeclarations of nested classes, since both would cause us
|
||||
// to try to instantiate the members of a class twice.
|
||||
|
@ -2609,7 +2605,7 @@ Sema::InstantiateClassMembers(SourceLocation PointOfInstantiation,
|
|||
if (Pattern)
|
||||
InstantiateClassMembers(PointOfInstantiation, Pattern, TemplateArgs,
|
||||
TSK);
|
||||
} else if (EnumDecl *Enum = dyn_cast<EnumDecl>(*D)) {
|
||||
} else if (auto *Enum = dyn_cast<EnumDecl>(D)) {
|
||||
MemberSpecializationInfo *MSInfo = Enum->getMemberSpecializationInfo();
|
||||
assert(MSInfo && "No member specialization information?");
|
||||
|
||||
|
|
|
@ -2595,9 +2595,8 @@ uint64_t ASTWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
|
|||
RecordData Record;
|
||||
Record.push_back(DECL_CONTEXT_LEXICAL);
|
||||
SmallVector<KindDeclIDPair, 64> Decls;
|
||||
for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
|
||||
D != DEnd; ++D)
|
||||
Decls.push_back(std::make_pair((*D)->getKind(), GetDeclRef(*D)));
|
||||
for (const auto *D : DC->decls())
|
||||
Decls.push_back(std::make_pair(D->getKind(), GetDeclRef(D)));
|
||||
|
||||
++NumLexicalDeclContexts;
|
||||
Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record, data(Decls));
|
||||
|
@ -4050,11 +4049,9 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
|
|||
// translation unit that do not come from other AST files.
|
||||
const TranslationUnitDecl *TU = Context.getTranslationUnitDecl();
|
||||
SmallVector<KindDeclIDPair, 64> NewGlobalDecls;
|
||||
for (DeclContext::decl_iterator I = TU->noload_decls_begin(),
|
||||
E = TU->noload_decls_end();
|
||||
I != E; ++I) {
|
||||
if (!(*I)->isFromASTFile())
|
||||
NewGlobalDecls.push_back(std::make_pair((*I)->getKind(), GetDeclRef(*I)));
|
||||
for (const auto *I : TU->noload_decls()) {
|
||||
if (!I->isFromASTFile())
|
||||
NewGlobalDecls.push_back(std::make_pair(I->getKind(), GetDeclRef(I)));
|
||||
}
|
||||
|
||||
llvm::BitCodeAbbrev *Abv = new llvm::BitCodeAbbrev();
|
||||
|
|
|
@ -101,9 +101,8 @@ static void Scan(IvarUsageMap& M, const ObjCContainerDecl *D) {
|
|||
|
||||
static void Scan(IvarUsageMap &M, const DeclContext *C, const FileID FID,
|
||||
SourceManager &SM) {
|
||||
for (DeclContext::decl_iterator I=C->decls_begin(), E=C->decls_end();
|
||||
I!=E; ++I)
|
||||
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
|
||||
for (const auto *I : C->decls())
|
||||
if (const auto *FD = dyn_cast<FunctionDecl>(I)) {
|
||||
SourceLocation L = FD->getLocStart();
|
||||
if (SM.getFileID(L) == FID)
|
||||
Scan(M, FD->getBody());
|
||||
|
|
|
@ -980,13 +980,11 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) {
|
|||
|
||||
// Get all the Decls in the DeclContext, and sort them with the
|
||||
// additional ones we've collected. Then visit them.
|
||||
for (DeclContext::decl_iterator I = D->decls_begin(), E = D->decls_end();
|
||||
I!=E; ++I) {
|
||||
Decl *subDecl = *I;
|
||||
if (!subDecl || subDecl->getLexicalDeclContext() != D ||
|
||||
subDecl->getLocStart().isInvalid())
|
||||
for (auto *SubDecl : D->decls()) {
|
||||
if (!SubDecl || SubDecl->getLexicalDeclContext() != D ||
|
||||
SubDecl->getLocStart().isInvalid())
|
||||
continue;
|
||||
DeclsInContainer.push_back(subDecl);
|
||||
DeclsInContainer.push_back(SubDecl);
|
||||
}
|
||||
|
||||
// Now sort the Decls so that they appear in lexical order.
|
||||
|
|
|
@ -173,10 +173,9 @@ public:
|
|||
IvarE = D->ivar_end(); IvarI != IvarE; ++IvarI) {
|
||||
IndexCtx.indexDecl(*IvarI);
|
||||
}
|
||||
for (DeclContext::decl_iterator
|
||||
I = D->decls_begin(), E = D->decls_end(); I != E; ++I) {
|
||||
if (!isa<ObjCIvarDecl>(*I))
|
||||
IndexCtx.indexDecl(*I);
|
||||
for (const auto *I : D->decls()) {
|
||||
if (!isa<ObjCIvarDecl>(I))
|
||||
IndexCtx.indexDecl(I);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -337,10 +336,8 @@ void IndexingContext::indexDecl(const Decl *D) {
|
|||
}
|
||||
|
||||
void IndexingContext::indexDeclContext(const DeclContext *DC) {
|
||||
for (DeclContext::decl_iterator
|
||||
I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I) {
|
||||
indexDecl(*I);
|
||||
}
|
||||
for (const auto *I : DC->decls())
|
||||
indexDecl(I);
|
||||
}
|
||||
|
||||
void IndexingContext::indexTopLevelDecl(const Decl *D) {
|
||||
|
|
Loading…
Reference in New Issue