forked from OSchip/llvm-project
DependencyScanning: pull factory function into MinimizedVFS, NFC
Avoid need for getBufferPtr API, simplifying another patch. No functionality change.
This commit is contained in:
parent
350fafabe9
commit
d07b290e4b
|
@ -217,9 +217,11 @@ public:
|
||||||
llvm::vfs::Status Stat)
|
llvm::vfs::Status Stat)
|
||||||
: Buffer(std::move(Buffer)), Stat(std::move(Stat)) {}
|
: Buffer(std::move(Buffer)), Stat(std::move(Stat)) {}
|
||||||
|
|
||||||
llvm::ErrorOr<llvm::vfs::Status> status() override { return Stat; }
|
static llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
|
||||||
|
create(const CachedFileSystemEntry *Entry,
|
||||||
|
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings);
|
||||||
|
|
||||||
const llvm::MemoryBuffer *getBufferPtr() const { return Buffer.get(); }
|
llvm::ErrorOr<llvm::vfs::Status> status() override { return Stat; }
|
||||||
|
|
||||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
|
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
|
||||||
getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
|
getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator,
|
||||||
|
@ -234,9 +236,11 @@ private:
|
||||||
llvm::vfs::Status Stat;
|
llvm::vfs::Status Stat;
|
||||||
};
|
};
|
||||||
|
|
||||||
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
|
} // end anonymous namespace
|
||||||
createFile(const CachedFileSystemEntry *Entry,
|
|
||||||
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
|
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>> MinimizedVFSFile::create(
|
||||||
|
const CachedFileSystemEntry *Entry,
|
||||||
|
ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings) {
|
||||||
if (Entry->isDirectory())
|
if (Entry->isDirectory())
|
||||||
return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>(
|
return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>(
|
||||||
std::make_error_code(std::errc::is_a_directory));
|
std::make_error_code(std::errc::is_a_directory));
|
||||||
|
@ -248,14 +252,12 @@ createFile(const CachedFileSystemEntry *Entry,
|
||||||
/*RequiresNullTerminator=*/false),
|
/*RequiresNullTerminator=*/false),
|
||||||
*Entry->getStatus());
|
*Entry->getStatus());
|
||||||
if (!Entry->getPPSkippedRangeMapping().empty() && PPSkipMappings)
|
if (!Entry->getPPSkippedRangeMapping().empty() && PPSkipMappings)
|
||||||
(*PPSkipMappings)[Result->getBufferPtr()] =
|
(*PPSkipMappings)[Result->Buffer.get()] =
|
||||||
&Entry->getPPSkippedRangeMapping();
|
&Entry->getPPSkippedRangeMapping();
|
||||||
return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>(
|
return llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>(
|
||||||
std::unique_ptr<llvm::vfs::File>(std::move(Result)));
|
std::unique_ptr<llvm::vfs::File>(std::move(Result)));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end anonymous namespace
|
|
||||||
|
|
||||||
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
|
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
|
||||||
DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) {
|
DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) {
|
||||||
SmallString<256> OwnedFilename;
|
SmallString<256> OwnedFilename;
|
||||||
|
@ -265,5 +267,5 @@ DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) {
|
||||||
getOrCreateFileSystemEntry(Filename);
|
getOrCreateFileSystemEntry(Filename);
|
||||||
if (!Result)
|
if (!Result)
|
||||||
return Result.getError();
|
return Result.getError();
|
||||||
return createFile(Result.get(), PPSkipMappings);
|
return MinimizedVFSFile::create(Result.get(), PPSkipMappings);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue