auto FID = SM.getFileID(Info.getLocation());
if (const auto FE = SM.getFileEntryRefForID(FID)) {
D.File = FE->getName().str();
- D.AbsFile = getCanonicalPath(*FE, SM);
+ D.AbsFile = getCanonicalPath(*FE, SM.getFileManager());
}
D.ID = Info.getID();
return D;
include_cleaner::Header Provider) {
if (Provider.kind() == include_cleaner::Header::Physical) {
if (auto CanonicalPath = getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager())) {
+ AST.getSourceManager().getFileManager())) {
std::string SpelledHeader =
llvm::cantFail(URI::includeSpelling(URI::create(*CanonicalPath)));
if (!SpelledHeader.empty())
}
std::optional<std::string> getCanonicalPath(const FileEntryRef F,
- const SourceManager &SourceMgr) {
+ FileManager &FileMgr) {
llvm::SmallString<128> FilePath = F.getName();
if (!llvm::sys::path::is_absolute(FilePath)) {
if (auto EC =
- SourceMgr.getFileManager().getVirtualFileSystem().makeAbsolute(
+ FileMgr.getVirtualFileSystem().makeAbsolute(
FilePath)) {
elog("Could not turn relative path '{0}' to absolute: {1}", FilePath,
EC.message());
//
// The file path of Symbol is "/project/src/foo.h" instead of
// "/tmp/build/foo.h"
- if (auto Dir = SourceMgr.getFileManager().getDirectory(
+ if (auto Dir = FileMgr.getDirectory(
llvm::sys::path::parent_path(FilePath))) {
llvm::SmallString<128> RealPath;
- llvm::StringRef DirName = SourceMgr.getFileManager().getCanonicalName(*Dir);
+ llvm::StringRef DirName = FileMgr.getCanonicalName(*Dir);
llvm::sys::path::append(RealPath, DirName,
llvm::sys::path::filename(FilePath));
return RealPath.str().str();
/// component that generate it, so that paths are normalized as much as
/// possible.
std::optional<std::string> getCanonicalPath(const FileEntryRef F,
- const SourceManager &SourceMgr);
+ FileManager &FileMgr);
/// Choose the clang-format style we should apply to a certain file.
/// This will usually use FS to look for .clang-format directories.
const auto F = SM.getFileEntryRefForID(SM.getFileID(Loc));
if (!F)
return std::nullopt;
- auto FilePath = getCanonicalPath(*F, SM);
+ auto FilePath = getCanonicalPath(*F, SM.getFileManager());
if (!FilePath) {
log("failed to get path!");
return std::nullopt;
const auto FE = SM.getFileEntryRefForID(SM.getFileID(NameLoc));
if (!FE)
return std::nullopt;
- auto FilePath = getCanonicalPath(*FE, SM);
+ auto FilePath = getCanonicalPath(*FE, SM.getFileManager());
if (!FilePath)
return std::nullopt; // Not useful without a uri.
const auto F = SM.getFileEntryRefForID(FID);
if (!F)
return false; // Skip invalid files.
- auto AbsPath = getCanonicalPath(*F, SM);
+ auto AbsPath = getCanonicalPath(*F, SM.getFileManager());
if (!AbsPath)
return false; // Skip files without absolute path.
auto Digest = digestFile(SM, FID);
const std::string &toURI(const FileEntryRef FE) {
auto R = CacheFEToURI.try_emplace(FE);
if (R.second) {
- auto CanonPath = getCanonicalPath(FE, SM);
+ auto CanonPath = getCanonicalPath(FE, SM.getFileManager());
R.first->second = &toURIInternal(CanonPath ? *CanonPath : FE.getName());
}
return *R.first->second;
const auto F = SM.getFileEntryRefForID(FID);
if (!F)
return false; // Skip invalid files.
- auto AbsPath = getCanonicalPath(*F, SM);
+ auto AbsPath = getCanonicalPath(*F, SM.getFileManager());
if (!AbsPath)
return false; // Skip files without absolute path.
std::lock_guard<std::mutex> Lock(FilesMu);
tooling::Replacements Replacements) {
Edit Ed(SM.getBufferData(FID), std::move(Replacements));
if (const auto FE = SM.getFileEntryRefForID(FID))
- if (auto FilePath = getCanonicalPath(*FE, SM))
+ if (auto FilePath = getCanonicalPath(*FE, SM.getFileManager()))
return std::make_pair(*FilePath, std::move(Ed));
return error("Failed to get absolute path for edited file: {0}",
SM.getFileEntryRefForID(FID)->getName());