Skip to content

Commit 1b07d43

Browse files
committed
[clang] NFCI: Use FileEntryRef in ModuleMap::InferredModuleAllowedBy
1 parent 86735a4 commit 1b07d43

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
@@ -259,8 +259,8 @@ class ModuleMap {
259259
Attributes Attrs;
260260

261261
/// If \c InferModules is non-zero, the module map file that allowed
262-
/// inferred modules. Otherwise, nullptr.
263-
const FileEntry *ModuleMapFile;
262+
/// inferred modules. Otherwise, nullopt.
263+
OptionalFileEntryRef ModuleMapFile;
264264

265265
/// The names of modules that cannot be inferred within this
266266
/// directory.
@@ -275,7 +275,8 @@ class ModuleMap {
275275

276276
/// A mapping from an inferred module to the module map that allowed the
277277
/// inference.
278-
llvm::DenseMap<const Module *, const FileEntry *> InferredModuleAllowedBy;
278+
// FIXME: Consider making the values non-optional.
279+
llvm::DenseMap<const Module *, OptionalFileEntryRef> InferredModuleAllowedBy;
279280

280281
llvm::DenseMap<const Module *, AdditionalModMapsSet> AdditionalModMaps;
281282

@@ -631,7 +632,7 @@ class ModuleMap {
631632
/// getContainingModuleMapFile().
632633
OptionalFileEntryRef getModuleMapFileForUniquing(const Module *M) const;
633634

634-
void setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap);
635+
void setInferredModuleAllowedBy(Module *M, OptionalFileEntryRef ModMap);
635636

636637
/// Canonicalize \p Path in a manner suitable for a module map file. In
637638
/// 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
@@ -525,15 +525,15 @@ static Module *prepareToBuildModule(CompilerInstance &CI,
525525
StringRef OriginalModuleMapName = CI.getFrontendOpts().OriginalModuleMap;
526526
if (!OriginalModuleMapName.empty()) {
527527
auto OriginalModuleMap =
528-
CI.getFileManager().getFile(OriginalModuleMapName,
529-
/*openFile*/ true);
528+
CI.getFileManager().getOptionalFileRef(OriginalModuleMapName,
529+
/*openFile*/ true);
530530
if (!OriginalModuleMap) {
531531
CI.getDiagnostics().Report(diag::err_module_map_not_found)
532532
<< OriginalModuleMapName;
533533
return nullptr;
534534
}
535-
if (*OriginalModuleMap != CI.getSourceManager().getFileEntryForID(
536-
CI.getSourceManager().getMainFileID())) {
535+
if (*OriginalModuleMap != CI.getSourceManager().getFileEntryRefForID(
536+
CI.getSourceManager().getMainFileID())) {
537537
M->IsInferred = true;
538538
CI.getPreprocessor().getHeaderSearchInfo().getModuleMap()
539539
.setInferredModuleAllowedBy(M, *OriginalModuleMap);

clang/lib/Lex/ModuleMap.cpp

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

624624
if (UmbrellaModule->InferSubmodules) {
625-
OptionalFileEntryRefDegradesToFileEntryPtr UmbrellaModuleMap =
625+
OptionalFileEntryRef UmbrellaModuleMap =
626626
getModuleMapFileForUniquing(UmbrellaModule);
627627

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

994994
// If the framework has a parent path from which we're allowed to infer
995995
// a framework module, do so.
996-
const FileEntry *ModuleMapFile = nullptr;
996+
OptionalFileEntryRef ModuleMapFile;
997997
if (!Parent) {
998998
// Determine whether we're allowed to infer a module map.
999999
bool canInfer = false;
@@ -1294,13 +1294,13 @@ OptionalFileEntryRef
12941294
ModuleMap::getModuleMapFileForUniquing(const Module *M) const {
12951295
if (M->IsInferred) {
12961296
assert(InferredModuleAllowedBy.count(M) && "missing inferred module map");
1297-
// FIXME: Update InferredModuleAllowedBy to use FileEntryRef.
1298-
return InferredModuleAllowedBy.find(M)->second->getLastRef();
1297+
return InferredModuleAllowedBy.find(M)->second;
12991298
}
13001299
return getContainingModuleMapFile(M);
13011300
}
13021301

1303-
void ModuleMap::setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap) {
1302+
void ModuleMap::setInferredModuleAllowedBy(Module *M,
1303+
OptionalFileEntryRef ModMap) {
13041304
assert(M->IsInferred && "module not inferred");
13051305
InferredModuleAllowedBy[M] = ModMap;
13061306
}

0 commit comments

Comments
 (0)