[clang] NFCI: Use FileEntryRef
in FileManager::getCanonicalName()
This commit is contained in:
parent
f5592f3069
commit
5a3130e3b6
@ -327,7 +327,7 @@ public:
|
||||
/// 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 FileEntry *File);
|
||||
StringRef getCanonicalName(FileEntryRef File);
|
||||
|
||||
private:
|
||||
/// Retrieve the canonical name for a given file or directory.
|
||||
|
@ -636,8 +636,8 @@ StringRef FileManager::getCanonicalName(DirectoryEntryRef Dir) {
|
||||
return getCanonicalName(Dir, Dir.getName());
|
||||
}
|
||||
|
||||
StringRef FileManager::getCanonicalName(const FileEntry *File) {
|
||||
return getCanonicalName(File, File->getName());
|
||||
StringRef FileManager::getCanonicalName(FileEntryRef File) {
|
||||
return getCanonicalName(File, File.getName());
|
||||
}
|
||||
|
||||
StringRef FileManager::getCanonicalName(const void *Entry, StringRef Name) {
|
||||
|
@ -177,17 +177,17 @@ struct LocationFileChecker {
|
||||
if (FID.isInvalid())
|
||||
return false;
|
||||
|
||||
const auto *File = SM.getFileEntryForID(FID);
|
||||
OptionalFileEntryRef File = SM.getFileEntryRefForID(FID);
|
||||
if (!File)
|
||||
return false;
|
||||
|
||||
if (KnownFileEntries.count(File))
|
||||
if (KnownFileEntries.count(*File))
|
||||
return true;
|
||||
|
||||
if (ExternalFileEntries.count(File))
|
||||
if (ExternalFileEntries.count(*File))
|
||||
return false;
|
||||
|
||||
StringRef FileName = SM.getFileManager().getCanonicalName(File);
|
||||
StringRef FileName = SM.getFileManager().getCanonicalName(*File);
|
||||
|
||||
// Try to reduce the include name the same way we tried to include it.
|
||||
bool IsQuoted = false;
|
||||
@ -197,13 +197,13 @@ struct LocationFileChecker {
|
||||
return KnownFile.first.equals(*IncludeName) &&
|
||||
KnownFile.second == IsQuoted;
|
||||
})) {
|
||||
KnownFileEntries.insert(File);
|
||||
KnownFileEntries.insert(*File);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Record that the file was not found to avoid future reverse lookup for
|
||||
// the same file.
|
||||
ExternalFileEntries.insert(File);
|
||||
ExternalFileEntries.insert(*File);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ void DependencyCollector::maybeAddDependency(StringRef Filename,
|
||||
bool IsMissing) {
|
||||
if (sawDependency(Filename, FromModule, IsSystem, IsModuleFile, IsMissing)) {
|
||||
if (IsSystem && FileMgr && shouldCanonicalizeSystemDependencies()) {
|
||||
if (auto F = FileMgr->getFile(Filename))
|
||||
if (auto F = FileMgr->getOptionalFileRef(Filename))
|
||||
Filename = FileMgr->getCanonicalName(*F);
|
||||
}
|
||||
addDependency(Filename);
|
||||
|
@ -164,8 +164,7 @@ SARIFDiagnostic::addDiagnosticLevelToRule(SarifRule Rule,
|
||||
llvm::StringRef SARIFDiagnostic::emitFilename(StringRef Filename,
|
||||
const SourceManager &SM) {
|
||||
if (DiagOpts->AbsolutePath) {
|
||||
llvm::ErrorOr<const FileEntry *> File =
|
||||
SM.getFileManager().getFile(Filename);
|
||||
auto File = SM.getFileManager().getOptionalFileRef(Filename);
|
||||
if (File) {
|
||||
// We want to print a simplified absolute path, i. e. without "dots".
|
||||
//
|
||||
@ -182,7 +181,7 @@ llvm::StringRef SARIFDiagnostic::emitFilename(StringRef Filename,
|
||||
// on Windows we can just use llvm::sys::path::remove_dots(), because,
|
||||
// on that system, both aforementioned paths point to the same place.
|
||||
#ifdef _WIN32
|
||||
SmallString<256> TmpFilename = (*File)->getName();
|
||||
SmallString<256> TmpFilename = File->getName();
|
||||
llvm::sys::fs::make_absolute(TmpFilename);
|
||||
llvm::sys::path::native(TmpFilename);
|
||||
llvm::sys::path::remove_dots(TmpFilename, /* remove_dot_dot */ true);
|
||||
|
@ -736,7 +736,7 @@ void TextDiagnostic::emitFilename(StringRef Filename, const SourceManager &SM) {
|
||||
SmallString<4096> TmpFilename;
|
||||
#endif
|
||||
if (DiagOpts->AbsolutePath) {
|
||||
auto File = SM.getFileManager().getFile(Filename);
|
||||
auto File = SM.getFileManager().getOptionalFileRef(Filename);
|
||||
if (File) {
|
||||
// We want to print a simplified absolute path, i. e. without "dots".
|
||||
//
|
||||
@ -753,7 +753,7 @@ void TextDiagnostic::emitFilename(StringRef Filename, const SourceManager &SM) {
|
||||
// on Windows we can just use llvm::sys::path::remove_dots(), because,
|
||||
// on that system, both aforementioned paths point to the same place.
|
||||
#ifdef _WIN32
|
||||
TmpFilename = (*File)->getName();
|
||||
TmpFilename = File->getName();
|
||||
llvm::sys::fs::make_absolute(TmpFilename);
|
||||
llvm::sys::path::native(TmpFilename);
|
||||
llvm::sys::path::remove_dots(TmpFilename, /* remove_dot_dot */ true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user