This patch removes the last use of deprecated `DirectoryEntry::getName()`.
Depends on D151855.
Reviewed By: benlangmuir
Differential Revision: https://reviews.llvm.org/D151922
<< '\n';
// Handle symbolic link path cases.
// We are trying to get the real file path of the symlink.
- auto Dir = SM.getFileManager().getDirectory(
+ auto Dir = SM.getFileManager().getOptionalDirectoryRef(
llvm::sys::path::parent_path(AbsolutePath.str()));
if (Dir) {
StringRef DirName = SM.getFileManager().getCanonicalName(*Dir);
//
// The file path of Symbol is "/project/src/foo.h" instead of
// "/tmp/build/foo.h"
- if (auto Dir = FileMgr.getDirectory(
+ if (auto Dir = FileMgr.getOptionalDirectoryRef(
llvm::sys::path::parent_path(FilePath))) {
llvm::SmallString<128> RealPath;
llvm::StringRef DirName = FileMgr.getCanonicalName(*Dir);
/// This is a very expensive operation, despite its results being cached,
/// and should only be used when the physical layout of the file system is
/// required, which is (almost) never.
- StringRef getCanonicalName(const DirectoryEntry *Dir);
+ StringRef getCanonicalName(DirectoryEntryRef Dir);
/// Retrieve the canonical name for a given file.
///
UIDToFiles[VFE->getUID()] = VFE;
}
-StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
- llvm::DenseMap<const void *, llvm::StringRef>::iterator Known
- = CanonicalNames.find(Dir);
+StringRef FileManager::getCanonicalName(DirectoryEntryRef Dir) {
+ auto Known = CanonicalNames.find(Dir);
if (Known != CanonicalNames.end())
return Known->second;
- StringRef CanonicalName(Dir->getName());
+ StringRef CanonicalName(Dir.getName());
SmallString<4096> CanonicalNameBuf;
- if (!FS->getRealPath(Dir->getName(), CanonicalNameBuf))
+ if (!FS->getRealPath(Dir.getName(), CanonicalNameBuf))
CanonicalName = CanonicalNameBuf.str().copy(CanonicalNameStorage);
CanonicalNames.insert({Dir, CanonicalName});
}
FileManager &FM = SourceMgr.getFileManager();
- auto DirEntry = FM.getDirectory(Dir.empty() ? "." : Dir);
+ auto DirEntry = FM.getDirectoryRef(Dir.empty() ? "." : Dir);
if (!DirEntry)
- return DirEntry.getError();
+ return llvm::errorToErrorCode(DirEntry.takeError());
// Canonicalize the directory.
StringRef CanonicalDir = FM.getCanonicalName(*DirEntry);