rmaz updated this revision to Diff 492829. rmaz added a comment. Use FileEntryRef for AddTopHeader()
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D142724/new/ https://reviews.llvm.org/D142724 Files: clang/include/clang/Basic/Module.h clang/lib/Basic/Module.cpp clang/lib/Frontend/FrontendAction.cpp clang/lib/Lex/ModuleMap.cpp clang/lib/Serialization/ASTWriter.cpp clang/tools/libclang/CIndex.cpp
Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -8788,7 +8788,7 @@ return 0; Module *Mod = static_cast<Module *>(CXMod); FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager(); - ArrayRef<const FileEntry *> TopHeaders = Mod->getTopHeaders(FileMgr); + auto TopHeaders = Mod->getTopHeaders(FileMgr); return TopHeaders.size(); } @@ -8803,9 +8803,9 @@ Module *Mod = static_cast<Module *>(CXMod); FileManager &FileMgr = cxtu::getASTUnit(TU)->getFileManager(); - ArrayRef<const FileEntry *> TopHeaders = Mod->getTopHeaders(FileMgr); + auto TopHeaders = Mod->getTopHeaders(FileMgr); if (Index < TopHeaders.size()) - return const_cast<FileEntry *>(TopHeaders[Index]); + return const_cast<FileEntry *>(&TopHeaders[Index].getFileEntry()); return nullptr; } Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ 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); } Index: clang/lib/Lex/ModuleMap.cpp =================================================================== --- clang/lib/Lex/ModuleMap.cpp +++ 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. Index: clang/lib/Frontend/FrontendAction.cpp =================================================================== --- clang/lib/Frontend/FrontendAction.cpp +++ clang/lib/Frontend/FrontendAction.cpp @@ -353,7 +353,7 @@ // Add includes for each of these headers. for (auto HK : {Module::HK_Normal, Module::HK_Private}) { for (Module::Header &H : Module->Headers[HK]) { - Module->addTopHeader(H.Entry); + Module->addTopHeader(*H.Entry); // Use the path as specified in the module map file. We'll look for this // file relative to the module build directory (the directory containing // the module map file) so this will find the same file that we found @@ -365,7 +365,7 @@ // Note that Module->PrivateHeaders will not be a TopHeader. if (Module::Header UmbrellaHeader = Module->getUmbrellaHeader()) { - Module->addTopHeader(UmbrellaHeader.Entry); + Module->addTopHeader(*UmbrellaHeader.Entry); if (Module->Parent) // Include the umbrella header for submodules. addHeaderInclude(UmbrellaHeader.PathRelativeToRootModuleDirectory, @@ -423,7 +423,7 @@ llvm::sort(Headers, llvm::less_first()); for (auto &H : Headers) { // Include this header as part of the umbrella directory. - Module->addTopHeader(H.second); + Module->addTopHeader(*H.second); addHeaderInclude(H.first, Includes, LangOpts, Module->IsExternC); } } Index: clang/lib/Basic/Module.cpp =================================================================== --- clang/lib/Basic/Module.cpp +++ clang/lib/Basic/Module.cpp @@ -269,16 +269,13 @@ Umbrella.dyn_cast<const DirectoryEntry *>()}; } -void Module::addTopHeader(const FileEntry *File) { - assert(File); - TopHeaders.insert(File); -} +void Module::addTopHeader(FileEntryRef File) { TopHeaders.insert(File); } -ArrayRef<const FileEntry *> Module::getTopHeaders(FileManager &FileMgr) { +ArrayRef<FileEntryRef> Module::getTopHeaders(FileManager &FileMgr) { if (!TopHeaderNames.empty()) { for (std::vector<std::string>::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(); Index: clang/include/clang/Basic/Module.h =================================================================== --- clang/include/clang/Basic/Module.h +++ clang/include/clang/Basic/Module.h @@ -189,7 +189,7 @@ OptionalFileEntryRef ASTFile; /// The top-level headers associated with this module. - llvm::SmallSetVector<const FileEntry *, 2> TopHeaders; + llvm::SmallSetVector<FileEntryRef, 2> TopHeaders; /// top-level header filenames that aren't resolved to FileEntries yet. std::vector<std::string> TopHeaderNames; @@ -639,7 +639,7 @@ } /// Add a top-level header associated with this module. - void addTopHeader(const FileEntry *File); + void addTopHeader(FileEntryRef 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<const FileEntry *> getTopHeaders(FileManager &FileMgr); + ArrayRef<FileEntryRef> getTopHeaders(FileManager &FileMgr); /// Determine whether this module has declared its intention to /// directly use another module.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits