diff options
author | Ben Langmuir <blangmuir@apple.com> | 2022-10-04 15:08:08 -0700 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2022-10-05 13:12:43 -0700 |
commit | 5ea78c4113f8d2c8be24152f2dd0cadaea352c9d (patch) | |
tree | c0561866efb1c7cbe9b5b5e26ae615ef956c181d /clang/lib/Lex/ModuleMap.cpp | |
parent | 1888dc91ac872146d106de9f8ea73b9148c920ff (diff) | |
download | llvm-5ea78c4113f8d2c8be24152f2dd0cadaea352c9d.zip llvm-5ea78c4113f8d2c8be24152f2dd0cadaea352c9d.tar.gz llvm-5ea78c4113f8d2c8be24152f2dd0cadaea352c9d.tar.bz2 |
[clang] Update ModuleMap::getModuleMapFile* to use FileEntryRef
Update SourceManager::ContentCache::OrigEntry to keep the original
FileEntryRef, and use that to enable ModuleMap::getModuleMapFile* to
return the original FileEntryRef. This change should be NFC for
most users of SourceManager::ContentCache, but it could affect behaviour
for users of getNameAsRequested such as in compileModuleImpl. I have not
found a way to detect that difference without additional functional
changes, other than incidental cases like changes from / to \ on
Windows so there is no new test.
Differential Revision: https://reviews.llvm.org/D135220
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 174d639..dbb81dc 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -609,7 +609,7 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(const FileEntry *File) { UmbrellaModule = UmbrellaModule->Parent; if (UmbrellaModule->InferSubmodules) { - const FileEntry *UmbrellaModuleMap = + OptionalFileEntryRefDegradesToFileEntryPtr UmbrellaModuleMap = getModuleMapFileForUniquing(UmbrellaModule); // Infer submodules for each of the directories we found between @@ -1023,9 +1023,11 @@ Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir, // If we're not allowed to infer a framework module, don't. if (!canInfer) return nullptr; - } else - ModuleMapFile = getModuleMapFileForUniquing(Parent); - + } else { + OptionalFileEntryRefDegradesToFileEntryPtr ModuleMapRef = + getModuleMapFileForUniquing(Parent); + ModuleMapFile = ModuleMapRef; + } // Look for an umbrella header. SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName()); @@ -1277,19 +1279,21 @@ void ModuleMap::excludeHeader(Module *Mod, Module::Header Header) { Mod->Headers[Module::HK_Excluded].push_back(std::move(Header)); } -const FileEntry * +Optional<FileEntryRef> ModuleMap::getContainingModuleMapFile(const Module *Module) const { if (Module->DefinitionLoc.isInvalid()) - return nullptr; + return None; - return SourceMgr.getFileEntryForID( - SourceMgr.getFileID(Module->DefinitionLoc)); + return SourceMgr.getFileEntryRefForID( + SourceMgr.getFileID(Module->DefinitionLoc)); } -const FileEntry *ModuleMap::getModuleMapFileForUniquing(const Module *M) const { +Optional<FileEntryRef> +ModuleMap::getModuleMapFileForUniquing(const Module *M) const { if (M->IsInferred) { assert(InferredModuleAllowedBy.count(M) && "missing inferred module map"); - return InferredModuleAllowedBy.find(M)->second; + // FIXME: Update InferredModuleAllowedBy to use FileEntryRef. + return InferredModuleAllowedBy.find(M)->second->getLastRef(); } return getContainingModuleMapFile(M); } |