Skip to content

Commit

Permalink
[clang] NFCI: Use the *Ref() variant on search paths
Browse files Browse the repository at this point in the history
This removes some uses of the deprecated `DirectoryEntry::getName()`.
  • Loading branch information
jansvoboda11 committed May 31, 2023
1 parent 5be0e83 commit 2d817d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/StdLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) &&
Expand Down
17 changes: 8 additions & 9 deletions clang/lib/Lex/HeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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){
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 2d817d0

Please sign in to comment.