summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-07-23 00:53:59 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-07-23 00:53:59 +0000
commit787c0e42e0d7d4aa1df35241f07672295de916c8 (patch)
tree192628921abdc399adbef58f00f50924879082e5 /clang
parentdbb4622ce39e2f4d060c4006dec1cf826acc297b (diff)
downloadbcm5719-llvm-787c0e42e0d7d4aa1df35241f07672295de916c8.tar.gz
bcm5719-llvm-787c0e42e0d7d4aa1df35241f07672295de916c8.zip
ArrayRef-ize a pointer/length pair.
llvm-svn: 242977
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Serialization/Module.h5
-rw-r--r--clang/lib/Serialization/ASTReader.cpp27
2 files changed, 15 insertions, 17 deletions
diff --git a/clang/include/clang/Serialization/Module.h b/clang/include/clang/Serialization/Module.h
index 5ae9ec7d19a..1d9fb0bfe8d 100644
--- a/clang/include/clang/Serialization/Module.h
+++ b/clang/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<reader::ASTDeclContextNameLookupTrait>
*NameLookupTableData; // an ASTDeclContextNameLookupTable.
- const KindDeclIDPair *LexicalDecls;
- unsigned NumLexicalDecls;
+ ArrayRef<KindDeclIDPair> LexicalDecls;
};
/// \brief The input file that has been loaded from this AST file, along with
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index c6fe363d7b5..73985fe2286 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -973,8 +973,9 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M,
return true;
}
- Info.LexicalDecls = reinterpret_cast<const KindDeclIDPair*>(Blob.data());
- Info.NumLexicalDecls = Blob.size() / sizeof(KindDeclIDPair);
+ Info.LexicalDecls = llvm::makeArrayRef(
+ reinterpret_cast<const KindDeclIDPair *>(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<const KindDeclIDPair *>(Blob.data());
- Info.NumLexicalDecls
- = static_cast<unsigned int>(Blob.size() / sizeof(KindDeclIDPair));
+ Info.LexicalDecls = llvm::makeArrayRef(
+ reinterpret_cast<const KindDeclIDPair *>(Blob.data()),
+ static_cast<unsigned int>(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);
}
OpenPOWER on IntegriCloud