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 /lib/Sema/SemaInit.cpp | |
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
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
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; |