10#include "llvm/Support/Path.h"
17 const std::size_t Offset = Buffer.size();
26 return FilePaths.size() - 1;
30 return Paths.
add(Dir);
40 StringRef CurrentWorkDir, StringRef SysRoot, llvm::StringRef OutputFile)
41 : WorkDir(CurrentWorkDir),
42 SysRoot(
llvm::sys::path::parent_path(SysRoot).empty() ? StringRef()
44 WorkDirPath(Paths.addDirPath(WorkDir)),
45 SysRootPath(Paths.addDirPath(SysRoot)),
46 OutputFilePath(Paths.addDirPath(OutputFile)) {}
49 auto FileIt = UniqueFiles.find(FE);
50 if (FileIt != UniqueFiles.end())
51 return FileIt->second;
53 const auto Dir = tryStoreDirPath(sys::path::parent_path(FE.
getName()));
57 UniqueFiles.try_emplace(FE, FileIdx);
63 while (Dir.size() > 1 && llvm::sys::path::is_separator(Dir.back()))
64 Dir = Dir.drop_back();
66 auto DirIt = UniqueDirs.find(Dir);
67 if (DirIt != UniqueDirs.end())
70 const std::string OrigDir = Dir.str();
73 if (!SysRoot.empty() && Dir.starts_with(SysRoot) &&
74 llvm::sys::path::is_separator(Dir[SysRoot.size()])) {
76 Dir = Dir.drop_front(SysRoot.size());
77 }
else if (!WorkDir.empty() && Dir.starts_with(WorkDir) &&
78 llvm::sys::path::is_separator(Dir[WorkDir.size()])) {
80 Dir = Dir.drop_front(WorkDir.size());
84 while (!Dir.empty() && llvm::sys::path::is_separator(Dir.front()))
85 Dir = Dir.drop_front();
89 UniqueDirs.try_emplace(OrigDir,
Result);
A reference to a FileEntry that includes the name of the file as it was accessed by the FileManager's...
StringRef getName() const
The name of this FileEntry.
size_t addFilePath(RootDirKind Root, const StringPool::StringOffsetSize &Dir, StringRef Filename)
StringPool::StringOffsetSize addDirPath(StringRef Dir)
StringRef getPaths() const
llvm::ArrayRef< FilePath > getFilePaths() const
RootDirKind
Special root directory of a filesystem path.
size_t tryStoreFilePath(FileEntryRef FE)
Stores path to FE if it hasn't been stored yet.
SerializablePathCollection(llvm::StringRef CurrentWorkDir, llvm::StringRef SysRoot, llvm::StringRef OutputFile)
StringOffsetSize add(StringRef Str)
StringRef getBuffer() const
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.
Diagnostic wrappers for TextAPI types for error reporting.