From: Richard Smith Date: Thu, 23 Jul 2015 00:53:59 +0000 (+0000) Subject: ArrayRef-ize a pointer/length pair. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=577ec0fa8ab3a07d9d29b1d84e5948df018b1b99;p=clang ArrayRef-ize a pointer/length pair. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242977 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 5ae9ec7d19..1d9fb0bfe8 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -53,12 +53,11 @@ enum ModuleKind { /// \brief Information about the contents of a DeclContext. struct DeclContextInfo { DeclContextInfo() - : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {} + : NameLookupTableData(), LexicalDecls() {} llvm::OnDiskIterableChainedHashTable *NameLookupTableData; // an ASTDeclContextNameLookupTable. - const KindDeclIDPair *LexicalDecls; - unsigned NumLexicalDecls; + ArrayRef LexicalDecls; }; /// \brief The input file that has been loaded from this AST file, along with diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index c6fe363d7b..73985fe228 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -973,8 +973,9 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M, return true; } - Info.LexicalDecls = reinterpret_cast(Blob.data()); - Info.NumLexicalDecls = Blob.size() / sizeof(KindDeclIDPair); + Info.LexicalDecls = llvm::makeArrayRef( + reinterpret_cast(Blob.data()), + Blob.size() / sizeof(KindDeclIDPair)); } // Now the lookup table. @@ -2496,9 +2497,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) { case TU_UPDATE_LEXICAL: { DeclContext *TU = Context.getTranslationUnitDecl(); DeclContextInfo &Info = F.DeclContextInfos[TU]; - Info.LexicalDecls = reinterpret_cast(Blob.data()); - Info.NumLexicalDecls - = static_cast(Blob.size() / sizeof(KindDeclIDPair)); + Info.LexicalDecls = llvm::makeArrayRef( + reinterpret_cast(Blob.data()), + static_cast(Blob.size() / sizeof(KindDeclIDPair))); TU->setHasExternalLexicalStorage(true); break; } @@ -6202,26 +6203,24 @@ namespace { ModuleFile::DeclContextInfosMap::iterator Info = M.DeclContextInfos.find(This->DC); - if (Info == M.DeclContextInfos.end() || !Info->second.LexicalDecls) + if (Info == M.DeclContextInfos.end() || Info->second.LexicalDecls.empty()) return false; // Load all of the declaration IDs - for (const KindDeclIDPair *ID = Info->second.LexicalDecls, - *IDE = ID + Info->second.NumLexicalDecls; - ID != IDE; ++ID) { - if (This->isKindWeWant && !This->isKindWeWant((Decl::Kind)ID->first)) + for (const KindDeclIDPair &P : Info->second.LexicalDecls) { + if (This->isKindWeWant && !This->isKindWeWant((Decl::Kind)P.first)) continue; // Don't add predefined declarations to the lexical context more // than once. - if (ID->second < NUM_PREDEF_DECL_IDS) { - if (This->PredefsVisited[ID->second]) + if (P.second < NUM_PREDEF_DECL_IDS) { + if (This->PredefsVisited[P.second]) continue; - This->PredefsVisited[ID->second] = true; + This->PredefsVisited[P.second] = true; } - if (Decl *D = This->Reader.GetLocalDecl(M, ID->second)) { + if (Decl *D = This->Reader.GetLocalDecl(M, P.second)) { if (!This->DC->isDeclInLexicalTraversal(D)) This->Decls.push_back(D); }