[PATCH] D127648: [clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::inferFrameworkModule()
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 13 08:19:35 PDT 2022
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: bnbarham.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This patch changes the argument type of `ModuleMap::inferFrameworkModule()` from `const DirectoryEntry *` to `DirectoryEntryRef` in order to remove the deprecated uses of `DirectoryEntry::getName()`.
Depends on D127647 <https://reviews.llvm.org/D127647>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127648
Files:
clang/include/clang/Lex/ModuleMap.h
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Lex/ModuleMap.cpp
Index: clang/lib/Lex/ModuleMap.cpp
===================================================================
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -942,14 +942,14 @@
}
}
-Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
+Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
bool IsSystem, Module *Parent) {
Attributes Attrs;
Attrs.IsSystem = IsSystem;
return inferFrameworkModule(FrameworkDir, Attrs, Parent);
}
-Module *ModuleMap::inferFrameworkModule(const DirectoryEntry *FrameworkDir,
+Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
Attributes Attrs, Module *Parent) {
// Note: as an egregious but useful hack we use the real path here, because
// we might be looking at an embedded framework that symlinks out to a
@@ -980,7 +980,7 @@
if (llvm::sys::path::has_parent_path(FrameworkDirName)) {
// Figure out the parent path.
StringRef Parent = llvm::sys::path::parent_path(FrameworkDirName);
- if (auto ParentDir = FileMgr.getDirectory(Parent)) {
+ if (auto ParentDir = FileMgr.getOptionalDirectoryRef(Parent)) {
// Check whether we have already looked into the parent directory
// for a module map.
llvm::DenseMap<const DirectoryEntry *, InferredDirectory>::const_iterator
@@ -1025,7 +1025,7 @@
// Look for an umbrella header.
- SmallString<128> UmbrellaName = StringRef(FrameworkDir->getName());
+ SmallString<128> UmbrellaName = StringRef(FrameworkDir.getName());
llvm::sys::path::append(UmbrellaName, "Headers", ModuleName + ".h");
auto UmbrellaHeader = FileMgr.getFile(UmbrellaName);
@@ -1070,8 +1070,7 @@
// Look for subframeworks.
std::error_code EC;
- SmallString<128> SubframeworksDirName
- = StringRef(FrameworkDir->getName());
+ SmallString<128> SubframeworksDirName = StringRef(FrameworkDir.getName());
llvm::sys::path::append(SubframeworksDirName, "Frameworks");
llvm::sys::path::native(SubframeworksDirName);
llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
@@ -1082,8 +1081,7 @@
if (!StringRef(Dir->path()).endswith(".framework"))
continue;
- if (auto SubframeworkDir =
- FileMgr.getDirectory(Dir->path())) {
+ if (auto SubframeworkDir = FileMgr.getOptionalDirectoryRef(Dir->path())) {
// Note: as an egregious but useful hack, we use the real path here and
// check whether it is actually a subdirectory of the parent directory.
// This will not be the case if the 'subframework' is actually a symlink
Index: clang/lib/Frontend/FrontendAction.cpp
===================================================================
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -466,7 +466,8 @@
SmallString<128> InferredFrameworkPath = ModuleMap->getDir().getName();
llvm::sys::path::append(InferredFrameworkPath,
CI.getLangOpts().ModuleName + ".framework");
- if (auto Dir = CI.getFileManager().getDirectory(InferredFrameworkPath))
+ if (auto Dir =
+ CI.getFileManager().getOptionalDirectoryRef(InferredFrameworkPath))
(void)HS.getModuleMap().inferFrameworkModule(*Dir, IsSystem, nullptr);
}
Index: clang/include/clang/Lex/ModuleMap.h
===================================================================
--- clang/include/clang/Lex/ModuleMap.h
+++ clang/include/clang/Lex/ModuleMap.h
@@ -374,8 +374,8 @@
return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
}
- Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir,
- Attributes Attrs, Module *Parent);
+ Module *inferFrameworkModule(DirectoryEntryRef FrameworkDir, Attributes Attrs,
+ Module *Parent);
public:
/// Construct a new module map.
@@ -570,8 +570,8 @@
/// Infer the contents of a framework module map from the given
/// framework directory.
- Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir,
- bool IsSystem, Module *Parent);
+ Module *inferFrameworkModule(DirectoryEntryRef FrameworkDir, bool IsSystem,
+ Module *Parent);
/// Create a new top-level module that is shadowed by
/// \p ShadowingModule.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127648.436401.patch
Type: text/x-patch
Size: 4437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220613/c6fae6bd/attachment.bin>
More information about the cfe-commits
mailing list