[clang] 2d817d0 - [clang] NFCI: Use the `*Ref()` variant on search paths
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Wed May 31 16:04:55 PDT 2023
Author: Jan Svoboda
Date: 2023-05-31T16:04:45-07:00
New Revision: 2d817d0368ee72e2bd97bad88434cba2df30be8a
URL: https://github.com/llvm/llvm-project/commit/2d817d0368ee72e2bd97bad88434cba2df30be8a
DIFF: https://github.com/llvm/llvm-project/commit/2d817d0368ee72e2bd97bad88434cba2df30be8a.diff
LOG: [clang] NFCI: Use the `*Ref()` variant on search paths
This removes some uses of the deprecated `DirectoryEntry::getName()`.
Added:
Modified:
clang-tools-extra/clangd/index/StdLib.cpp
clang/lib/Lex/HeaderSearch.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/index/StdLib.cpp b/clang-tools-extra/clangd/index/StdLib.cpp
index 381d599e3d2aa..d9aa46d6b75b1 100644
--- a/clang-tools-extra/clangd/index/StdLib.cpp
+++ b/clang-tools-extra/clangd/index/StdLib.cpp
@@ -314,7 +314,7 @@ std::optional<StdLibLocation> StdLibSet::add(const LangOptions &LO,
llvm::make_range(HS.search_dir_begin(), HS.search_dir_end())) {
switch (DL.getLookupType()) {
case DirectoryLookup::LT_NormalDir: {
- Path = DL.getDir()->getName();
+ Path = DL.getDirRef()->getName();
llvm::sys::path::append(Path, ProbeHeader);
llvm::vfs::Status Stat;
if (!HS.getFileMgr().getNoncachedStatValue(Path, Stat) &&
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 3366f158fd4f7..7e8f93ab172ad 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -311,7 +311,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
// SearchName rather than ModuleName, to permit finding private modules
// named FooPrivate in buggy frameworks named Foo.
SmallString<128> FrameworkDirName;
- FrameworkDirName += Dir.getFrameworkDir()->getName();
+ FrameworkDirName += Dir.getFrameworkDirRef()->getName();
llvm::sys::path::append(FrameworkDirName, SearchName + ".framework");
if (auto FrameworkDir =
FileMgr.getOptionalDirectoryRef(FrameworkDirName)) {
@@ -345,7 +345,7 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName,
// Search for a module map in a subdirectory with the same name as the
// module.
SmallString<128> NestedModuleMapDirName;
- NestedModuleMapDirName = Dir.getDir()->getName();
+ NestedModuleMapDirName = Dir.getDirRef()->getName();
llvm::sys::path::append(NestedModuleMapDirName, ModuleName);
if (loadModuleMapFile(NestedModuleMapDirName, IsSystem,
/*IsFramework*/false) == LMM_NewlyLoaded){
@@ -405,11 +405,10 @@ void HeaderSearch::indexInitialHeaderMaps() {
/// getName - Return the directory or filename corresponding to this lookup
/// object.
StringRef DirectoryLookup::getName() const {
- // FIXME: Use the name from \c DirectoryEntryRef.
if (isNormalDir())
- return getDir()->getName();
+ return getDirRef()->getName();
if (isFramework())
- return getFrameworkDir()->getName();
+ return getFrameworkDirRef()->getName();
assert(isHeaderMap() && "Unknown DirectoryLookup");
return getHeaderMap()->getFileName();
}
@@ -1840,7 +1839,7 @@ void HeaderSearch::collectAllModules(SmallVectorImpl<Module *> &Modules) {
if (DL.isFramework()) {
std::error_code EC;
SmallString<128> DirNative;
- llvm::sys::path::native(DL.getFrameworkDir()->getName(), DirNative);
+ llvm::sys::path::native(DL.getFrameworkDirRef()->getName(), DirNative);
// Search each of the ".framework" directories to load them as modules.
llvm::vfs::FileSystem &FS = FileMgr.getVirtualFileSystem();
@@ -1903,7 +1902,7 @@ void HeaderSearch::loadSubdirectoryModuleMaps(DirectoryLookup &SearchDir) {
return;
std::error_code EC;
- SmallString<128> Dir = SearchDir.getDir()->getName();
+ SmallString<128> Dir = SearchDir.getDirRef()->getName();
FileMgr.makeAbsolutePath(Dir);
SmallString<128> DirNative;
llvm::sys::path::native(Dir, DirNative);
@@ -1986,14 +1985,14 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics(
bool BestPrefixIsFramework = false;
for (const DirectoryLookup &DL : search_dir_range()) {
if (DL.isNormalDir()) {
- StringRef Dir = DL.getDir()->getName();
+ StringRef Dir = DL.getDirRef()->getName();
if (CheckDir(Dir)) {
if (IsSystem)
*IsSystem = BestPrefixLength && isSystem(DL.getDirCharacteristic());
BestPrefixIsFramework = false;
}
} else if (DL.isFramework()) {
- StringRef Dir = DL.getFrameworkDir()->getName();
+ StringRef Dir = DL.getFrameworkDirRef()->getName();
if (CheckDir(Dir)) {
if (IsSystem)
*IsSystem = BestPrefixLength && isSystem(DL.getDirCharacteristic());
More information about the cfe-commits
mailing list