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/Serialization | |
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/Serialization')
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 9 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 15 | ||||
-rw-r--r-- | lib/Serialization/ASTWriterDecl.cpp | 9 |
3 files changed, 17 insertions, 16 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 94f13948b5..dfef31c277 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1819,10 +1819,11 @@ ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) { } if (DC->isNamespace()) { - for (DeclContext::lookup_result R = DC->lookup(Name); - R.first != R.second; ++R.first) { - if (isSameEntity(*R.first, D)) - return FindExistingResult(Reader, D, *R.first); + DeclContext::lookup_result R = DC->lookup(Name); + for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; + ++I) { + if (isSameEntity(*I, D)) + return FindExistingResult(Reader, D, *I); } } diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 1b39f551bf..58f7fe7051 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -2947,7 +2947,7 @@ public: clang::io::Emit16(Out, KeyLen); // 2 bytes for num of decls and 4 for each DeclID. - unsigned DataLen = 2 + 4 * (Lookup.second - Lookup.first); + unsigned DataLen = 2 + 4 * Lookup.size(); clang::io::Emit16(Out, DataLen); return std::make_pair(KeyLen, DataLen); @@ -2987,9 +2987,10 @@ public: void EmitData(raw_ostream& Out, key_type_ref, data_type Lookup, unsigned DataLen) { uint64_t Start = Out.tell(); (void)Start; - clang::io::Emit16(Out, Lookup.second - Lookup.first); - for (; Lookup.first != Lookup.second; ++Lookup.first) - clang::io::Emit32(Out, Writer.GetDeclRef(*Lookup.first)); + clang::io::Emit16(Out, Lookup.size()); + for (DeclContext::lookup_iterator I = Lookup.begin(), E = Lookup.end(); + I != E; ++I) + clang::io::Emit32(Out, Writer.GetDeclRef(*I)); assert(Out.tell() - Start == DataLen && "Data length is wrong"); } @@ -3038,7 +3039,7 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context, D != DEnd; ++D) { DeclarationName Name = D->first; DeclContext::lookup_result Result = D->second.getLookupResult(); - if (Result.first != Result.second) { + if (!Result.empty()) { if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName) { // Hash all conversion function names to the same name. The actual // type information in conversion function name is not used in the @@ -3047,7 +3048,7 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context, // functions under a single key. if (!ConversionName) ConversionName = Name; - ConversionDecls.append(Result.first, Result.second); + ConversionDecls.append(Result.begin(), Result.end()); continue; } @@ -3106,7 +3107,7 @@ void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) { DeclContext::lookup_result Result = D->second.getLookupResult(); // For any name that appears in this table, the results are complete, i.e. // they overwrite results from previous PCHs. Merging is always a mess. - if (Result.first != Result.second) + if (!Result.empty()) Generator.insert(Name, Result, Trait); } diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index dfafc16511..bc92fb714a 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -841,11 +841,10 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) { if (StoredDeclsMap *Map = NS->buildLookup()) { for (StoredDeclsMap::iterator D = Map->begin(), DEnd = Map->end(); D != DEnd; ++D) { - DeclContext::lookup_result Result = D->second.getLookupResult(); - while (Result.first != Result.second) { - Writer.GetDeclRef(*Result.first); - ++Result.first; - } + DeclContext::lookup_result R = D->second.getLookupResult(); + for (DeclContext::lookup_iterator I = R.begin(), E = R.end(); I != E; + ++I) + Writer.GetDeclRef(*I); } } } |