[clang] NFCI: Use FileEntryRef
in ModuleMapParser
This commit is contained in:
parent
ef996175a7
commit
c23d65b90f
@ -721,7 +721,7 @@ public:
|
|||||||
/// that caused us to load this module map file, if any.
|
/// that caused us to load this module map file, if any.
|
||||||
///
|
///
|
||||||
/// \returns true if an error occurred, false otherwise.
|
/// \returns true if an error occurred, false otherwise.
|
||||||
bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
|
bool parseModuleMapFile(FileEntryRef File, bool IsSystem,
|
||||||
DirectoryEntryRef HomeDir, FileID ID = FileID(),
|
DirectoryEntryRef HomeDir, FileID ID = FileID(),
|
||||||
unsigned *Offset = nullptr,
|
unsigned *Offset = nullptr,
|
||||||
SourceLocation ExternModuleLoc = SourceLocation());
|
SourceLocation ExternModuleLoc = SourceLocation());
|
||||||
|
@ -1660,7 +1660,7 @@ bool HeaderSearch::findUsableModuleForFrameworkHeader(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const FileEntry *getPrivateModuleMap(FileEntryRef File,
|
static OptionalFileEntryRef getPrivateModuleMap(FileEntryRef File,
|
||||||
FileManager &FileMgr) {
|
FileManager &FileMgr) {
|
||||||
StringRef Filename = llvm::sys::path::filename(File.getName());
|
StringRef Filename = llvm::sys::path::filename(File.getName());
|
||||||
SmallString<128> PrivateFilename(File.getDir().getName());
|
SmallString<128> PrivateFilename(File.getDir().getName());
|
||||||
@ -1669,10 +1669,8 @@ static const FileEntry *getPrivateModuleMap(FileEntryRef File,
|
|||||||
else if (Filename == "module.modulemap")
|
else if (Filename == "module.modulemap")
|
||||||
llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
|
llvm::sys::path::append(PrivateFilename, "module.private.modulemap");
|
||||||
else
|
else
|
||||||
return nullptr;
|
return std::nullopt;
|
||||||
if (auto File = FileMgr.getFile(PrivateFilename))
|
return FileMgr.getOptionalFileRef(PrivateFilename);
|
||||||
return *File;
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
|
bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
|
||||||
@ -1738,8 +1736,8 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, bool IsSystem,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Try to load a corresponding private module map.
|
// Try to load a corresponding private module map.
|
||||||
if (const FileEntry *PMMFile = getPrivateModuleMap(File, FileMgr)) {
|
if (OptionalFileEntryRef PMMFile = getPrivateModuleMap(File, FileMgr)) {
|
||||||
if (ModMap.parseModuleMapFile(PMMFile, IsSystem, Dir)) {
|
if (ModMap.parseModuleMapFile(*PMMFile, IsSystem, Dir)) {
|
||||||
LoadedModuleMaps[File] = false;
|
LoadedModuleMaps[File] = false;
|
||||||
return LMM_InvalidModuleMap;
|
return LMM_InvalidModuleMap;
|
||||||
}
|
}
|
||||||
|
@ -1490,7 +1490,7 @@ namespace clang {
|
|||||||
ModuleMap ⤅
|
ModuleMap ⤅
|
||||||
|
|
||||||
/// The current module map file.
|
/// The current module map file.
|
||||||
const FileEntry *ModuleMapFile;
|
FileEntryRef ModuleMapFile;
|
||||||
|
|
||||||
/// Source location of most recent parsed module declaration
|
/// Source location of most recent parsed module declaration
|
||||||
SourceLocation CurrModuleDeclLoc;
|
SourceLocation CurrModuleDeclLoc;
|
||||||
@ -1562,7 +1562,7 @@ namespace clang {
|
|||||||
public:
|
public:
|
||||||
explicit ModuleMapParser(Lexer &L, SourceManager &SourceMgr,
|
explicit ModuleMapParser(Lexer &L, SourceManager &SourceMgr,
|
||||||
const TargetInfo *Target, DiagnosticsEngine &Diags,
|
const TargetInfo *Target, DiagnosticsEngine &Diags,
|
||||||
ModuleMap &Map, const FileEntry *ModuleMapFile,
|
ModuleMap &Map, FileEntryRef ModuleMapFile,
|
||||||
DirectoryEntryRef Directory, bool IsSystem)
|
DirectoryEntryRef Directory, bool IsSystem)
|
||||||
: L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),
|
: L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),
|
||||||
ModuleMapFile(ModuleMapFile), Directory(Directory),
|
ModuleMapFile(ModuleMapFile), Directory(Directory),
|
||||||
@ -2095,7 +2095,7 @@ void ModuleMapParser::parseModuleDecl() {
|
|||||||
ActiveModule->NoUndeclaredIncludes = true;
|
ActiveModule->NoUndeclaredIncludes = true;
|
||||||
ActiveModule->Directory = Directory;
|
ActiveModule->Directory = Directory;
|
||||||
|
|
||||||
StringRef MapFileName(ModuleMapFile->getName());
|
StringRef MapFileName(ModuleMapFile.getName());
|
||||||
if (MapFileName.endswith("module.private.modulemap") ||
|
if (MapFileName.endswith("module.private.modulemap") ||
|
||||||
MapFileName.endswith("module_private.map")) {
|
MapFileName.endswith("module_private.map")) {
|
||||||
ActiveModule->ModuleMapIsPrivate = true;
|
ActiveModule->ModuleMapIsPrivate = true;
|
||||||
@ -3077,7 +3077,7 @@ bool ModuleMapParser::parseModuleMapFile() {
|
|||||||
} while (true);
|
} while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModuleMap::parseModuleMapFile(const FileEntry *File, bool IsSystem,
|
bool ModuleMap::parseModuleMapFile(FileEntryRef File, bool IsSystem,
|
||||||
DirectoryEntryRef Dir, FileID ID,
|
DirectoryEntryRef Dir, FileID ID,
|
||||||
unsigned *Offset,
|
unsigned *Offset,
|
||||||
SourceLocation ExternModuleLoc) {
|
SourceLocation ExternModuleLoc) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user