diff --git a/clang/include/clang/Basic/Module.h b/clang/include/clang/Basic/Module.h --- a/clang/include/clang/Basic/Module.h +++ b/clang/include/clang/Basic/Module.h @@ -189,7 +189,7 @@ OptionalFileEntryRef ASTFile; /// The top-level headers associated with this module. - llvm::SmallSetVector TopHeaders; + llvm::SmallSetVector TopHeaders; /// top-level header filenames that aren't resolved to FileEntries yet. std::vector TopHeaderNames; @@ -639,7 +639,7 @@ } /// Add a top-level header associated with this module. - void addTopHeader(const FileEntry *File); + void addTopHeader(OptionalFileEntryRef File); /// Add a top-level header filename associated with this module. void addTopHeaderFilename(StringRef Filename) { @@ -647,7 +647,7 @@ } /// The top-level headers associated with this module. - ArrayRef getTopHeaders(FileManager &FileMgr); + ArrayRef getTopHeaders(FileManager &FileMgr); /// Determine whether this module has declared its intention to /// directly use another module. diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -269,16 +269,16 @@ Umbrella.dyn_cast()}; } -void Module::addTopHeader(const FileEntry *File) { +void Module::addTopHeader(OptionalFileEntryRef File) { assert(File); - TopHeaders.insert(File); + TopHeaders.insert(*File); } -ArrayRef Module::getTopHeaders(FileManager &FileMgr) { +ArrayRef Module::getTopHeaders(FileManager &FileMgr) { if (!TopHeaderNames.empty()) { for (std::vector::iterator I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) { - if (auto FE = FileMgr.getFile(*I)) + if (auto FE = FileMgr.getFileRef(*I)) TopHeaders.insert(*FE); } TopHeaderNames.clear(); diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -660,7 +660,7 @@ Explicit).first; InferredModuleAllowedBy[Result] = UmbrellaModuleMap; Result->IsInferred = true; - Result->addTopHeader(File); + Result->addTopHeader(File->getLastRef()); // If inferred submodules export everything they import, add a // wildcard to the set of exports. diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2878,8 +2878,8 @@ { auto TopHeaders = Mod->getTopHeaders(PP->getFileManager()); RecordData::value_type Record[] = {SUBMODULE_TOPHEADER}; - for (auto *H : TopHeaders) { - SmallString<128> HeaderName(H->getName()); + for (auto H : TopHeaders) { + SmallString<128> HeaderName(H.getName()); PreparePathForOutput(HeaderName); Stream.EmitRecordWithBlob(TopHeaderAbbrev, Record, HeaderName); } diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -8788,7 +8788,7 @@ return 0; Module *Mod = static_cast(CXMod); FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager(); - ArrayRef TopHeaders = Mod->getTopHeaders(FileMgr); + auto TopHeaders = Mod->getTopHeaders(FileMgr); return TopHeaders.size(); } @@ -8803,9 +8803,9 @@ Module *Mod = static_cast(CXMod); FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager(); - ArrayRef TopHeaders = Mod->getTopHeaders(FileMgr); + auto TopHeaders = Mod->getTopHeaders(FileMgr); if (Index < TopHeaders.size()) - return const_cast(TopHeaders[Index]); + return const_cast(&TopHeaders[Index].getFileEntry()); return nullptr; }