diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-12-19 00:45:41 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-12-19 00:45:41 +0000 |
commit | 3bc93e3124ad5e7191c4a12dc981c8ee53578193 (patch) | |
tree | 473bface3adcd2064712462246a506969b0284d8 | |
parent | 8a68da12c71efeeaca0ed24c39288a2117d07f9d (diff) |
Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as per review discussion in r170365
This does limit these typedefs to being sequences, but no current usage
requires them to be contiguous (we could expand this to a more general
iterator pair range concept at some point).
Also, it'd be nice if SmallVector were constructible directly from an ArrayRef
but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the
inverse conversion. (& generalizing over all range-like things, while nice,
would require some nontrivial SFINAE I haven't thought about yet)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170482 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/DeclBase.h | 24 | ||||
-rw-r--r-- | lib/AST/CXXInheritance.cpp | 22 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 10 | ||||
-rw-r--r-- | lib/AST/DeclCXX.cpp | 16 | ||||
-rw-r--r-- | lib/AST/DeclObjC.cpp | 16 | ||||
-rw-r--r-- | lib/AST/ExprCXX.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/MultiplexExternalSemaSource.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 7 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 43 | ||||
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 16 | ||||
-rw-r--r-- | lib/Sema/SemaInit.cpp | 24 | ||||
-rw-r--r-- | lib/Sema/SemaLambda.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 53 | ||||
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 14 | ||||
-rw-r--r-- | lib/Sema/TreeTransform.h | 4 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 9 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 15 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 9 |
22 files changed, 154 insertions, 170 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index c5b1a09aeb..e3fa41ef31 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -890,29 +890,9 @@ public: virtual void print(raw_ostream &OS) const; }; -class DeclContextLookupResult - : public std::pair<NamedDecl**,NamedDecl**> { -public: - DeclContextLookupResult(NamedDecl **I, NamedDecl **E) - : std::pair<NamedDecl**,NamedDecl**>(I, E) {} - DeclContextLookupResult() - : std::pair<NamedDecl**,NamedDecl**>() {} - - using std::pair<NamedDecl**,NamedDecl**>::operator=; -}; +typedef llvm::MutableArrayRef<NamedDecl*> DeclContextLookupResult; -class DeclContextLookupConstResult - : public std::pair<NamedDecl*const*, NamedDecl*const*> { -public: - DeclContextLookupConstResult(std::pair<NamedDecl**,NamedDecl**> R) - : std::pair<NamedDecl*const*, NamedDecl*const*>(R) {} - DeclContextLookupConstResult(NamedDecl * const *I, NamedDecl * const *E) - : std::pair<NamedDecl*const*, NamedDecl*const*>(I, E) {} - DeclContextLookupConstResult() - : std::pair<NamedDecl*const*, NamedDecl*const*>() {} - - using std::pair<NamedDecl*const*,NamedDecl*const*>::operator=; -}; +typedef llvm::ArrayRef<NamedDecl*> DeclContextLookupConstResult; /// DeclContext - This is used only as base class of specific decl types that /// can act as declaration contexts. These decls are (only the top classes diff --git a/lib/AST/CXXInheritance.cpp b/lib/AST/CXXInheritance.cpp index e0e3a69856..5083a010e1 100644 --- a/lib/AST/CXXInheritance.cpp +++ b/lib/AST/CXXInheritance.cpp @@ -28,7 +28,7 @@ void CXXBasePaths::ComputeDeclsFound() { llvm::SetVector<NamedDecl *, SmallVector<NamedDecl *, 8> > Decls; for (paths_iterator Path = begin(), PathEnd = end(); Path != PathEnd; ++Path) - Decls.insert(*Path->Decls.first); + Decls.insert(Path->Decls.front()); NumDeclsFound = Decls.size(); DeclsFound = new NamedDecl * [NumDeclsFound]; @@ -397,9 +397,9 @@ bool CXXRecordDecl::FindTagMember(const CXXBaseSpecifier *Specifier, DeclarationName N = DeclarationName::getFromOpaquePtr(Name); for (Path.Decls = BaseRecord->lookup(N); - Path.Decls.first != Path.Decls.second; - ++Path.Decls.first) { - if ((*Path.Decls.first)->isInIdentifierNamespace(IDNS_Tag)) + !Path.Decls.empty(); + Path.Decls = Path.Decls.slice(1)) { + if (Path.Decls.front()->isInIdentifierNamespace(IDNS_Tag)) return true; } @@ -415,9 +415,9 @@ bool CXXRecordDecl::FindOrdinaryMember(const CXXBaseSpecifier *Specifier, const unsigned IDNS = IDNS_Ordinary | IDNS_Tag | IDNS_Member; DeclarationName N = DeclarationName::getFromOpaquePtr(Name); for (Path.Decls = BaseRecord->lookup(N); - Path.Decls.first != Path.Decls.second; - ++Path.Decls.first) { - if ((*Path.Decls.first)->isInIdentifierNamespace(IDNS)) + !Path.Decls.empty(); + Path.Decls = Path.Decls.slice(1)) { + if (Path.Decls.front()->isInIdentifierNamespace(IDNS)) return true; } @@ -433,11 +433,11 @@ FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, DeclarationName N = DeclarationName::getFromOpaquePtr(Name); for (Path.Decls = BaseRecord->lookup(N); - Path.Decls.first != Path.Decls.second; - ++Path.Decls.first) { + !Path.Decls.empty(); + Path.Decls = Path.Decls.slice(1)) { // FIXME: Refactor the "is it a nested-name-specifier?" check - if (isa<TypedefNameDecl>(*Path.Decls.first) || - (*Path.Decls.first)->isInIdentifierNamespace(IDNS_Tag)) + if (isa<TypedefNameDecl>(Path.Decls.front()) || + Path.Decls.front()->isInIdentifierNamespace(IDNS_Tag)) return true; } diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 883e3fd698..5dccaac020 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -1206,7 +1206,7 @@ void DeclContext::localUncachedLookup(DeclarationName Name, // the results. if (!hasExternalVisibleStorage() && !hasExternalLexicalStorage() && Name) { lookup_result LookupResults = lookup(Name); - Results.insert(Results.end(), LookupResults.first, LookupResults.second); + Results.insert(Results.end(), LookupResults.begin(), LookupResults.end()); return; } @@ -1216,8 +1216,8 @@ void DeclContext::localUncachedLookup(DeclarationName Name, StoredDeclsMap::iterator Pos = Map->find(Name); if (Pos != Map->end()) { Results.insert(Results.end(), - Pos->second.getLookupResult().first, - Pos->second.getLookupResult().second); + Pos->second.getLookupResult().begin(), + Pos->second.getLookupResult().end()); return; } } @@ -1369,8 +1369,8 @@ DeclContext::getUsingDirectives() const { // FIXME: Use something more efficient than normal lookup for using // directives. In C++, using directives are looked up more than anything else. lookup_const_result Result = lookup(UsingDirectiveDecl::getName()); - return udir_iterator_range(reinterpret_cast<udir_iterator>(Result.first), - reinterpret_cast<udir_iterator>(Result.second)); + return udir_iterator_range(reinterpret_cast<udir_iterator>(Result.begin()), + reinterpret_cast<udir_iterator>(Result.end())); } //===----------------------------------------------------------------------===// diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 73d6ddd6a6..fcd38ac721 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -1159,12 +1159,11 @@ CXXDestructorDecl *CXXRecordDecl::getDestructor() const { = Context.DeclarationNames.getCXXDestructorName( Context.getCanonicalType(ClassType)); - DeclContext::lookup_const_iterator I, E; - llvm::tie(I, E) = lookup(Name); - if (I == E) + DeclContext::lookup_const_result R = lookup(Name); + if (R.empty()) return 0; - CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(*I); + CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(R.front()); return Dtor; } @@ -1278,7 +1277,7 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD, } lookup_const_result Candidates = RD->lookup(getDeclName()); - for (NamedDecl * const * I = Candidates.first; I != Candidates.second; ++I) { + for (NamedDecl * const * I = Candidates.begin(); I != Candidates.end(); ++I) { CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*I); if (!MD) continue; @@ -1353,9 +1352,10 @@ bool CXXMethodDecl::isUsualDeallocationFunction() const { // This function is a usual deallocation function if there are no // single-parameter deallocation functions of the same kind. - for (DeclContext::lookup_const_result R = getDeclContext()->lookup(getDeclName()); - R.first != R.second; ++R.first) { - if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*R.first)) + DeclContext::lookup_const_result R = getDeclContext()->lookup(getDeclName()); + for (DeclContext::lookup_const_result::iterator I = R.begin(), E = R.end(); + I != E; ++I) { + if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) if (FD->getNumParams() == 1) return false; } diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 2b7b13b43f..12e5d8c304 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -54,8 +54,9 @@ void ObjCContainerDecl::anchor() { } /// ObjCIvarDecl * ObjCContainerDecl::getIvarDecl(IdentifierInfo *Id) const { - lookup_const_iterator Ivar, IvarEnd; - for (llvm::tie(Ivar, IvarEnd) = lookup(Id); Ivar != IvarEnd; ++Ivar) { + lookup_const_result R = lookup(Id); + for (lookup_const_iterator Ivar = R.begin(), IvarEnd = R.end(); + Ivar != IvarEnd; ++Ivar) { if (ObjCIvarDecl *ivar = dyn_cast<ObjCIvarDecl>(*Ivar)) return ivar; } @@ -73,8 +74,9 @@ ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const { // + (float) class_method; // @end // - lookup_const_iterator Meth, MethEnd; - for (llvm::tie(Meth, MethEnd) = lookup(Sel); Meth != MethEnd; ++Meth) { + lookup_const_result R = lookup(Sel); + for (lookup_const_iterator Meth = R.begin(), MethEnd = R.end(); + Meth != MethEnd; ++Meth) { ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth); if (MD && MD->isInstanceMethod() == isInstance) return MD; @@ -86,9 +88,9 @@ ObjCPropertyDecl * ObjCPropertyDecl::findPropertyDecl(const DeclContext *DC, IdentifierInfo *propertyID) { - DeclContext::lookup_const_iterator I, E; - llvm::tie(I, E) = DC->lookup(propertyID); - for ( ; I != E; ++I) + DeclContext::lookup_const_result R = DC->lookup(propertyID); + for (DeclContext::lookup_const_iterator I = R.begin(), E = R.end(); I != E; + ++I) if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(*I)) return PD; diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 1dc7de1b4d..6c66c90cd4 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -964,9 +964,9 @@ CXXMethodDecl *LambdaExpr::getCallOperator() const { DeclarationName Name = Record->getASTContext().DeclarationNames.getCXXOperatorName(OO_Call); DeclContext::lookup_result Calls = Record->lookup(Name); - assert(Calls.first != Calls.second && "Missing lambda call operator!"); - CXXMethodDecl *Result = cast<CXXMethodDecl>(*Calls.first++); - assert(Calls.first == Calls.second && "More than lambda one call operator?"); + assert(!Calls.empty() && "Missing lambda call operator!"); + assert(Calls.size() == 1 && "More than one lambda call operator!"); + CXXMethodDecl *Result = cast<CXXMethodDecl>(Calls.front()); return Result; } diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 9df8905bcd..5d93a8bfef 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -1757,7 +1757,7 @@ void CodeGenFunction::EmitForwardingCallToLambda(const CXXRecordDecl *lambda, DeclarationName operatorName = getContext().DeclarationNames.getCXXOperatorName(OO_Call); CXXMethodDecl *callOperator = - cast<CXXMethodDecl>(*lambda->lookup(operatorName).first); + cast<CXXMethodDecl>(lambda->lookup(operatorName).front()); // Get the address of the call operator. const CGFunctionInfo &calleeFnInfo = diff --git a/lib/Sema/MultiplexExternalSemaSource.cpp b/lib/Sema/MultiplexExternalSemaSource.cpp index 8e03eb57e3..dca0a3549d 100644 --- a/lib/Sema/MultiplexExternalSemaSource.cpp +++ b/lib/Sema/MultiplexExternalSemaSource.cpp @@ -84,13 +84,13 @@ CXXBaseSpecifier *MultiplexExternalSemaSource::GetExternalCXXBaseSpecifiers( DeclContextLookupResult MultiplexExternalSemaSource:: FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) { StoredDeclsList DeclsFound; - DeclContextLookupResult lookup; for(size_t i = 0; i < Sources.size(); ++i) { - lookup = Sources[i]->FindExternalVisibleDeclsByName(DC, Name); - while(lookup.first != lookup.second) { - if (!DeclsFound.HandleRedeclaration(*lookup.first)) - DeclsFound.AddSubsequentDecl(*lookup.first); - lookup.first++; + DeclContext::lookup_result R = + Sources[i]->FindExternalVisibleDeclsByName(DC, Name); + for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; + ++I) { + if (!DeclsFound.HandleRedeclaration(*I)) + DeclsFound.AddSubsequentDecl(*I); } } return DeclsFound.getLookupResult(); diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 9e8f68c251..ab8cac8944 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -757,9 +757,10 @@ void ResultBuilder::MaybeAddConstructorResults(Result R) { DeclarationName ConstructorName = Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(RecordTy)); - for (DeclContext::lookup_result Ctors = Record->lookup(ConstructorName); - Ctors.first != Ctors.second; ++Ctors.first) { - R.Declaration = *Ctors.first; + DeclContext::lookup_result Ctors = Record->lookup(ConstructorName); + for (DeclContext::lookup_iterator I = Ctors.begin(), E = Ctors.end(); I != E; + ++I) { + R.Declaration = *I; R.CursorKind = getCursorKindForDecl(R.Declaration); Results.push_back(R); } diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7f98c3359c..96e911d17b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4789,9 +4789,9 @@ static bool FindOverriddenMethod(const CXXBaseSpecifier *Specifier, } for (Path.Decls = BaseRecord->lookup(Name); - Path.Decls.first != Path.Decls.second; - ++Path.Decls.first) { - NamedDecl *D = *Path.Decls.first; + !Path.Decls.empty(); + Path.Decls = Path.Decls.slice(1)) { + NamedDecl *D = Path.Decls.front(); if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) { if (MD->isVirtual() && !Data->S->IsOverload(Data->Method, MD, false)) return true; diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 502b358315..22aad165e9 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -295,12 +295,12 @@ static bool isIntOrBool(Expr *Exp) { static bool threadSafetyCheckIsSmartPointer(Sema &S, const RecordType* RT) { DeclContextLookupConstResult Res1 = RT->getDecl()->lookup( S.Context.DeclarationNames.getCXXOperatorName(OO_Star)); - if (Res1.first == Res1.second) + if (Res1.empty()) return false; DeclContextLookupConstResult Res2 = RT->getDecl()->lookup( S.Context.DeclarationNames.getCXXOperatorName(OO_Arrow)); - if (Res2.first == Res2.second) + if (Res2.empty()) return false; return true; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 027491cbbe..99366b6a6b 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -2119,10 +2119,10 @@ Sema::BuildMemInitializer(Decl *ConstructorD, // Look for a member, first. DeclContext::lookup_result Result = ClassDecl->lookup(MemberOrBase); - if (Result.first != Result.second) { + if (!Result.empty()) { ValueDecl *Member; - if ((Member = dyn_cast<FieldDecl>(*Result.first)) || - (Member = dyn_cast<IndirectFieldDecl>(*Result.first))) { + if ((Member = dyn_cast<FieldDecl>(Result.front())) || + (Member = dyn_cast<IndirectFieldDecl>(Result.front()))) { if (EllipsisLoc.isValid()) Diag(EllipsisLoc, diag::err_pack_expansion_member_init) << MemberOrBase @@ -3956,9 +3956,10 @@ void Sema::CheckCompletedCXXClass(CXXRecordDecl *Record) { // C++ [class.mem]p14: // In addition, if class T has a user-declared constructor (12.1), every // non-static data member of class T shall have a name different from T. - for (DeclContext::lookup_result R = Record->lookup(Record->getDeclName()); - R.first != R.second; ++R.first) { - NamedDecl *D = *R.first; + DeclContext::lookup_result R = Record->lookup(Record->getDeclName()); + for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; + ++I) { + NamedDecl *D = *I; if ((isa<FieldDecl>(D) && Record->hasUserDeclaredConstructor()) || isa<IndirectFieldDecl>(D)) { Diag(D->getLocation(), diag::err_member_name_of_class) @@ -5283,9 +5284,9 @@ static bool FindHiddenVirtualMethod(const CXXBaseSpecifier *Specifier, bool foundSameNameMethod = false; SmallVector<CXXMethodDecl *, 8> overloadedMethods; for (Path.Decls = BaseRecord->lookup(Name); - Path.Decls.first != Path.Decls.second; - ++Path.Decls.first) { - NamedDecl *D = *Path.Decls.first; + !Path.Decls.empty(); + Path.Decls = Path.Decls.slice(1)) { + NamedDecl *D = Path.Decls.front(); if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) { MD = MD->getCanonicalDecl(); foundSameNameMethod = true; @@ -5337,10 +5338,10 @@ void Sema::DiagnoseHiddenVirtualMethods(CXXRecordDecl *DC, CXXMethodDecl *MD) { // Keep the base methods that were overriden or introduced in the subclass // by 'using' in a set. A base method not in this set is hidden. - for (DeclContext::lookup_result res = DC->lookup(MD->getDeclName()); - res.first != res.second; ++res.first) { - NamedDecl *ND = *res.first; - if (UsingShadowDecl *shad = dyn_cast<UsingShadowDecl>(*res.first)) + DeclContext::lookup_result R = DC->lookup(MD->getDeclName()); + for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; ++I) { + NamedDecl *ND = *I; + if (UsingShadowDecl *shad = dyn_cast<UsingShadowDecl>(*I)) ND = shad->getTargetDecl(); if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(ND)) AddMostOverridenMethods(MD, Data.OverridenAndUsingBaseMethods); @@ -6025,11 +6026,11 @@ Decl *Sema::ActOnStartNamespaceDef(Scope *NamespcScope, Decl::IDNS_Type | Decl::IDNS_Using | Decl::IDNS_Tag | Decl::IDNS_Namespace; NamedDecl *PrevDecl = 0; - for (DeclContext::lookup_result R - = CurContext->getRedeclContext()->lookup(II); - R.first != R.second; ++R.first) { - if ((*R.first)->getIdentifierNamespace() & IDNS) { - PrevDecl = *R.first; + DeclContext::lookup_result R = CurContext->getRedeclContext()->lookup(II); + for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; + ++I) { + if ((*I)->getIdentifierNamespace() & IDNS) { + PrevDecl = *I; break; } } @@ -9393,8 +9394,8 @@ bool Sema::isImplicitlyDeleted(FunctionDecl *FD) { static void markLambdaCallOperatorUsed(Sema &S, CXXRecordDecl *Lambda) { CXXMethodDecl *CallOperator = cast<CXXMethodDecl>( - *Lambda->lookup( - S.Context.DeclarationNames.getCXXOperatorName(OO_Call)).first); + Lambda->lookup( + S.Context.DeclarationNames.getCXXOperatorName(OO_Call)).front()); CallOperator->setReferenced(); CallOperator->setUsed(); } @@ -9416,7 +9417,7 @@ void Sema::DefineImplicitLambdaToFunctionPointerConversion( // Return the address of the __invoke function. DeclarationName InvokeName = &Context.Idents.get("__invoke"); CXXMethodDecl *Invoke - = cast<CXXMethodDecl>(*Lambda->lookup(InvokeName).first); + = cast<CXXMethodDecl>(Lambda->lookup(InvokeName).front()); Expr *FunctionRef = BuildDeclRefExpr(Invoke, Invoke->getType(), VK_LValue, Conv->getLocation()).take(); assert(FunctionRef && "Can't refer to __invoke function?"); diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index e3df0a3275..4a93b118c6 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -1853,8 +1853,8 @@ void Sema::DeclareGlobalAllocationFunction(DeclarationName Name, // Check if this function is already declared. { - DeclContext::lookup_iterator Alloc, AllocEnd; - for (llvm::tie(Alloc, AllocEnd) = GlobalCtx->lookup(Name); + DeclContext::lookup_result R = GlobalCtx->lookup(Name); + for (DeclContext::lookup_iterator Alloc = R.begin(), AllocEnd = R.end(); Alloc != AllocEnd; ++Alloc) { // Only look at non-template functions, as it is the predefined, // non-templated allocation function we are trying to declare here. @@ -3191,9 +3191,9 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT, bool FoundConstructor = false; unsigned FoundTQs; - DeclContext::lookup_const_iterator Con, ConEnd; - for (llvm::tie(Con, ConEnd) = Self.LookupConstructors(RD); - Con != ConEnd; ++Con) { + DeclContext::lookup_const_result R = Self.LookupConstructors(RD); + for (DeclContext::lookup_const_iterator Con = R.begin(), + ConEnd = R.end(); Con != ConEnd; ++Con) { // A template constructor is never a copy constructor. // FIXME: However, it may actually be selected at the actual overload // resolution point. @@ -3230,9 +3230,9 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT, !RD->hasNonTrivialDefaultConstructor()) return true; - DeclContext::lookup_const_iterator Con, ConEnd; - for (llvm::tie(Con, ConEnd) = Self.LookupConstructors(RD); - Con != ConEnd; ++Con) { + DeclContext::lookup_const_result R = Self.LookupConstructors(RD); + for (DeclContext::lookup_const_iterator Con = R.begin(), + ConEnd = R.end(); Con != ConEnd; ++Con) { // FIXME: In C++0x, a constructor template can be a default constructor. if (isa<FunctionTemplateDecl>(*Con)) continue; diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index dcfd18b122..a5a0a11ed6 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -1706,7 +1706,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // struct/union. DeclContext::lookup_result Lookup = RT->getDecl()->lookup(FieldName); FieldDecl *ReplacementField = 0; - if (Lookup.first == Lookup.second) { + if (Lookup.empty()) { // Name lookup didn't find anything. Determine whether this // was a typo for another field name. FieldInitializerValidatorCCC Validator(RT->getDecl()); @@ -1739,7 +1739,7 @@ InitListChecker::CheckDesignatedInitializer(const InitializedEntity &Entity, // Name lookup found something, but it wasn't a field. SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_nonfield) << FieldName; - SemaRef.Diag((*Lookup.first)->getLocation(), + SemaRef.Diag(Lookup.front()->getLocation(), diag::note_field_designator_found); ++Index; return true; @@ -2842,12 +2842,11 @@ static void TryConstructorInitialization(Sema &S, // - Otherwise, if T is a class type, constructors are considered. The // applicable constructors are enumerated, and the best one is chosen // through overload resolution. - DeclContext::lookup_iterator ConStart, ConEnd; - llvm::tie(ConStart, ConEnd) = S.LookupConstructors(DestRecordDecl); + DeclContext::lookup_result R = S.LookupConstructors(DestRecordDecl); // The container holding the constructors can under certain conditions // be changed while iterating (e.g. because of deserialization). // To be safe we copy the lookup results to a new container. - SmallVector<NamedDecl*, 16> Ctors(ConStart, ConEnd); + SmallVector<NamedDecl*, 16> Ctors(R.begin(), R.end()); OverloadingResult Result = OR_No_Viable_Function; OverloadCandidateSet::iterator Best; @@ -3153,12 +3152,11 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, // to see if there is a suitable conversion. CXXRecordDecl *T1RecordDecl = cast<CXXRecordDecl>(T1RecordType->getDecl()); - DeclContext::lookup_iterator Con, ConEnd; - llvm::tie(Con, ConEnd) = S.LookupConstructors(T1RecordDecl); + DeclContext::lookup_result R = S.LookupConstructors(T1RecordDecl); // The container holding the constructors can under certain conditions // be changed while iterating (e.g. because of deserialization). // To be safe we copy the lookup results to a new container. - SmallVector<NamedDecl*, 16> Ctors(Con, ConEnd); + SmallVector<NamedDecl*, 16> Ctors(R.begin(), R.end()); for (SmallVector<NamedDecl*, 16>::iterator CI = Ctors.begin(), CE = Ctors.end(); CI != CE; ++CI) { NamedDecl *D = *CI; @@ -3723,12 +3721,11 @@ static void TryUserDefinedConversion(Sema &S, // Try to complete the type we're converting to. if (!S.RequireCompleteType(Kind.getLocation(), DestType, 0)) { - DeclContext::lookup_iterator ConOrig, ConEndOrig; - llvm::tie(ConOrig, ConEndOrig) = S.LookupConstructors(DestRecordDecl); + DeclContext::lookup_result R = S.LookupConstructors(DestRecordDecl); // The container holding the constructors can under certain conditions // be changed while iterating. To be safe we copy the lookup results // to a new container. - SmallVector<NamedDecl*, 8> CopyOfCon(ConOrig, ConEndOrig); + SmallVector<NamedDecl*, 8> CopyOfCon(R.begin(), R.end()); for (SmallVector<NamedDecl*, 8>::iterator Con = CopyOfCon.begin(), ConEnd = CopyOfCon.end(); Con != ConEnd; ++Con) { @@ -4351,12 +4348,11 @@ static void LookupCopyAndMoveConstructors(Sema &S, OverloadCandidateSet &CandidateSet, CXXRecordDecl *Class, Expr *CurInitExpr) { - DeclContext::lookup_iterator Con, ConEnd; - llvm::tie(Con, ConEnd) = S.LookupConstructors(Class); + DeclContext::lookup_result R = S.LookupConstructors(Class); // The container holding the constructors can under certain conditions // be changed while iterating (e.g. because of deserialization). // To be safe we copy the lookup results to a new container. - SmallVector<NamedDecl*, 16> Ctors(Con, ConEnd); + SmallVector<NamedDecl*, 16> Ctors(R.begin(), R.end()); for (SmallVector<NamedDecl*, 16>::iterator CI = Ctors.begin(), CE = Ctors.end(); CI != CE; ++CI) { NamedDecl *D = *CI; diff --git a/lib/Sema/SemaLambda.cpp b/lib/Sema/SemaLambda.cpp index c8810905d5..8ba14d51cc 100644 --- a/lib/Sema/SemaLambda.cpp +++ b/lib/Sema/SemaLambda.cpp @@ -902,8 +902,8 @@ ExprResult Sema::BuildBlockForLambdaConversion(SourceLocation CurrentLocation, CXXRecordDecl *Lambda = Conv->getParent(); CXXMethodDecl *CallOperator = cast<CXXMethodDecl>( - *Lambda->lookup( - Context.DeclarationNames.getCXXOperatorName(OO_Call)).first); + Lambda->lookup( + Context.DeclarationNames.getCXXOperatorName(OO_Call)).front()); CallOperator->setReferenced(); CallOperator->setUsed(); diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 41996b3e42..b17e0062f9 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -451,9 +451,9 @@ void LookupResult::resolveKind() { void LookupResult::addDeclsFromBasePaths(const CXXBasePaths &P) { CXXBasePaths::const_paths_iterator I, E; - DeclContext::lookup_iterator DI, DE; for (I = P.begin(), E = P.end(); I != E; ++I) - for (llvm::tie(DI,DE) = I->Decls; DI != DE; ++DI) + for (DeclContext::lookup_iterator DI = I->Decls.begin(), + DE = I->Decls.end(); DI != DE; ++DI) addDecl(*DI); } @@ -647,8 +647,9 @@ static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { DeclareImplicitMemberFunctionsWithName(S, R.getLookupName(), DC); // Perform lookup into this declaration context. - DeclContext::lookup_const_iterator I, E; - for (llvm::tie(I, E) = DC->lookup(R.getLookupName()); I != E; ++I) { + DeclContext::lookup_const_result DR = DC->lookup(R.getLookupName()); + for (DeclContext::lookup_const_iterator I = DR.begin(), E = DR.end(); I != E; + ++I) { NamedDecl *D = *I; if ((D = R.getAcceptableDecl(D))) { R.addDecl(D); @@ -1336,7 +1337,7 @@ static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, DeclarationName N = DeclarationName::getFromOpaquePtr(Name); Path.Decls = BaseRecord->lookup(N); - return Path.Decls.first != Path.Decls.second; + return !Path.Decls.empty(); } /// \brief Determine whether the given set of member declarations contains only @@ -1522,13 +1523,13 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // We found members of the given name in two subobjects of // different types. If the declaration sets aren't the same, this // this lookup is ambiguous. - if (HasOnlyStaticMembers(Path->Decls.first, Path->Decls.second)) { + if (HasOnlyStaticMembers(Path->Decls.begin(), Path->Decls.end())) { CXXBasePaths::paths_iterator FirstPath = Paths.begin(); - DeclContext::lookup_iterator FirstD = FirstPath->Decls.first; - DeclContext::lookup_iterator CurrentD = Path->Decls.first; + DeclContext::lookup_iterator FirstD = FirstPath->Decls.begin(); + DeclContext::lookup_iterator CurrentD = Path->Decls.begin(); - while (FirstD != FirstPath->Decls.second && - CurrentD != Path->Decls.second) { + while (FirstD != FirstPath->Decls.end() && + CurrentD != Path->Decls.end()) { if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() != (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl()) break; @@ -1537,8 +1538,8 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, ++CurrentD; } - if (FirstD == FirstPath->Decls.second && - CurrentD == Path->Decls.second) + if (FirstD == FirstPath->Decls.end() && + CurrentD == Path->Decls.end()) continue; } @@ -1553,7 +1554,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // A static member, a nested type or an enumerator defined in // a base class T can unambiguously be found even if an object // has more than one base class subobject of type T. - if (HasOnlyStaticMembers(Path->Decls.first, Path->Decls.second)) + if (HasOnlyStaticMembers(Path->Decls.begin(), Path->Decls.end())) continue; // We have found a nonstatic member name in multiple, distinct @@ -1565,8 +1566,8 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, // Lookup in a base class succeeded; return these results. - DeclContext::lookup_iterator I, E; - for (llvm::tie(I,E) = Paths.front().Decls; I != E; ++I) { + DeclContext::lookup_result DR = Paths.front().Decls; + for (DeclContext::lookup_iterator I = DR.begin(), E = DR.end(); I != E; ++I) { NamedDecl *D = *I; AccessSpecifier AS = CXXRecordDecl::MergeAccess(SubobjectAccess, D->getAccess()); @@ -1647,7 +1648,7 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { << Name << SubobjectType << getAmbiguousPathsDisplayString(*Paths) << LookupRange; - DeclContext::lookup_iterator Found = Paths->front().Decls.first; + DeclContext::lookup_iterator Found = Paths->front().Decls.begin(); while (isa<CXXMethodDecl>(*Found) && cast<CXXMethodDecl>(*Found)->isStatic()) ++Found; @@ -1666,7 +1667,7 @@ bool Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { for (CXXBasePaths::paths_iterator Path = Paths->begin(), PathEnd = Paths->end(); Path != PathEnd; ++Path) { - Decl *D = *Path->Decls.first; + Decl *D = Path->D |