Skip to content

Commit 6b8f65a

Browse files
jansvoboda11cachemeifyoucan
authored andcommitted
[clang] NFCI: Use FileEntryRef in ModuleMap::InferredModuleAllowedBy
(cherry picked from commit 1b07d43)
1 parent ec3adfa commit 6b8f65a

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

clang/include/clang/Lex/ModuleMap.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ class ModuleMap {
270270
Attributes Attrs;
271271

272272
/// If \c InferModules is non-zero, the module map file that allowed
273-
/// inferred modules. Otherwise, nullptr.
274-
const FileEntry *ModuleMapFile;
273+
/// inferred modules. Otherwise, nullopt.
274+
OptionalFileEntryRef ModuleMapFile;
275275

276276
/// The names of modules that cannot be inferred within this
277277
/// directory.
@@ -286,7 +286,8 @@ class ModuleMap {
286286

287287
/// A mapping from an inferred module to the module map that allowed the
288288
/// inference.
289-
llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
289+
// FIXME: Consider making the values non-optional.
290+
llvm::DenseMap<const Module *, OptionalFileEntryRef> InferredModuleAllowedBy;
290291

291292
llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
292293

@@ -641,7 +642,7 @@ class ModuleMap {
641642
/// getContainingModuleMapFile().
642643
OptionalFileEntryRef getModuleMapFileForUniquing(const Module *M) const;
643644

644-
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap);
645+
void setInferredModuleAllowedBy(Module *M, OptionalFileEntryRef ModMap);
645646

646647
/// Canonicalize \p Path in a manner suitable for a module map file. In
647648
/// particular, this canonicalizes the parent directory separately from the

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,15 @@ static Module *prepareToBuildModule(CompilerInstance &CI,
533533
StringRef OriginalModuleMapName = CI.getFrontendOpts().OriginalModuleMap;
534534
if (!OriginalModuleMapName.empty()) {
535535
auto OriginalModuleMap =
536-
CI.getFileManager().getFile(OriginalModuleMapName,
537-
/*openFile*/ true);
536+
CI.getFileManager().getOptionalFileRef(OriginalModuleMapName,
537+
/*openFile*/ true);
538538
if (!OriginalModuleMap) {
539539
CI.getDiagnostics().Report(diag::err_module_map_not_found)
540540
<< OriginalModuleMapName;
541541
return nullptr;
542542
}
543-
if (*OriginalModuleMap != CI.getSourceManager().getFileEntryForID(
544-
CI.getSourceManager().getMainFileID())) {
543+
if (*OriginalModuleMap != CI.getSourceManager().getFileEntryRefForID(
544+
CI.getSourceManager().getMainFileID())) {
545545
M->IsInferred = true;
546546
CI.getPreprocessor().getHeaderSearchInfo().getModuleMap()
547547
.setInferredModuleAllowedBy(M, *OriginalModuleMap);

clang/lib/Lex/ModuleMap.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ ModuleMap::findOrCreateModuleForHeaderInUmbrellaDir(FileEntryRef File) {
642642
UmbrellaModule = UmbrellaModule->Parent;
643643

644644
if (UmbrellaModule->InferSubmodules) {
645-
OptionalFileEntryRefDegradesToFileEntryPtr UmbrellaModuleMap =
645+
OptionalFileEntryRef UmbrellaModuleMap =
646646
getModuleMapFileForUniquing(UmbrellaModule);
647647

648648
// Infer submodules for each of the directories we found between
@@ -1022,7 +1022,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
10221022

10231023
// If the framework has a parent path from which we're allowed to infer
10241024
// a framework module, do so.
1025-
const FileEntry *ModuleMapFile = nullptr;
1025+
OptionalFileEntryRef ModuleMapFile;
10261026
if (!Parent) {
10271027
// Determine whether we're allowed to infer a module map.
10281028
bool canInfer = false;
@@ -1323,13 +1323,13 @@ OptionalFileEntryRef
13231323
ModuleMap::getModuleMapFileForUniquing(const Module *M) const {
13241324
if (M->IsInferred) {
13251325
assert(InferredModuleAllowedBy.count(M) && "missing inferred module map");
1326-
// FIXME: Update InferredModuleAllowedBy to use FileEntryRef.
1327-
return InferredModuleAllowedBy.find(M)->second->getLastRef();
1326+
return InferredModuleAllowedBy.find(M)->second;
13281327
}
13291328
return getContainingModuleMapFile(M);
13301329
}
13311330

1332-
void ModuleMap::setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap) {
1331+
void ModuleMap::setInferredModuleAllowedBy(Module *M,
1332+
OptionalFileEntryRef ModMap) {
13331333
assert(M->IsInferred && "module not inferred");
13341334
InferredModuleAllowedBy[M] = ModMap;
13351335
}

0 commit comments

Comments
 (0)