NFC: Clean up construction of IntrusiveRefCntPtr from raw pointers for llvm::vfs::FileSystem. (#151407)
This switches to `makeIntrusiveRefCnt<FileSystem>` where creating a new object, and to passing/returning by `IntrusiveRefCntPtr<FileSystem>` instead of `FileSystem*` or `FileSystem&`, when dealing with existing objects. Part of cleanup #151026.
This commit is contained in:
parent
920d5bbf0d
commit
9ddbb478ce
@ -420,6 +420,8 @@ public:
|
||||
/// @{
|
||||
|
||||
llvm::vfs::FileSystem &getVirtualFileSystem() const;
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
|
||||
getVirtualFileSystemPtr() const;
|
||||
|
||||
/// @}
|
||||
/// @name File Manager
|
||||
|
@ -2366,18 +2366,16 @@ size_t SourceManager::getDataStructureSizes() const {
|
||||
|
||||
SourceManagerForFile::SourceManagerForFile(StringRef FileName,
|
||||
StringRef Content) {
|
||||
// This is referenced by `FileMgr` and will be released by `FileMgr` when it
|
||||
// is deleted.
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
InMemoryFileSystem->addFile(
|
||||
FileName, 0,
|
||||
llvm::MemoryBuffer::getMemBuffer(Content, FileName,
|
||||
/*RequiresNullTerminator=*/false));
|
||||
// This is passed to `SM` as reference, so the pointer has to be referenced
|
||||
// in `Environment` so that `FileMgr` can out-live this function scope.
|
||||
FileMgr =
|
||||
std::make_unique<FileManager>(FileSystemOptions(), InMemoryFileSystem);
|
||||
FileMgr = std::make_unique<FileManager>(FileSystemOptions(),
|
||||
std::move(InMemoryFileSystem));
|
||||
DiagOpts = std::make_unique<DiagnosticOptions>();
|
||||
// This is passed to `SM` as reference, so the pointer has to be referenced
|
||||
// by `Environment` due to the same reason above.
|
||||
|
@ -978,7 +978,7 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
|
||||
CI.getPreprocessor());
|
||||
|
||||
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
|
||||
CI, BA, &CI.getVirtualFileSystem(), *VMContext, std::move(LinkModules),
|
||||
CI, BA, CI.getVirtualFileSystemPtr(), *VMContext, std::move(LinkModules),
|
||||
InFile, std::move(OS), CoverageInfo));
|
||||
BEConsumer = Result.get();
|
||||
|
||||
@ -1156,7 +1156,7 @@ void CodeGenAction::ExecuteAction() {
|
||||
|
||||
// Set clang diagnostic handler. To do this we need to create a fake
|
||||
// BackendConsumer.
|
||||
BackendConsumer Result(CI, BA, &CI.getVirtualFileSystem(), *VMContext,
|
||||
BackendConsumer Result(CI, BA, CI.getVirtualFileSystemPtr(), *VMContext,
|
||||
std::move(LinkModules), "", nullptr, nullptr,
|
||||
TheModule.get());
|
||||
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
: CI(CI), Diags(CI.getDiagnostics()), MainFileName(MainFileName),
|
||||
OutputFileName(OutputFileName), Ctx(nullptr),
|
||||
MMap(CI.getPreprocessor().getHeaderSearchInfo().getModuleMap()),
|
||||
FS(&CI.getVirtualFileSystem()),
|
||||
FS(CI.getVirtualFileSystemPtr()),
|
||||
HeaderSearchOpts(CI.getHeaderSearchOpts()),
|
||||
PreprocessorOpts(CI.getPreprocessorOpts()),
|
||||
TargetOpts(CI.getTargetOpts()), LangOpts(CI.getLangOpts()),
|
||||
|
@ -1773,7 +1773,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
|
||||
|
||||
if (AST->LoadFromCompilerInvocation(std::move(PCHContainerOps),
|
||||
PrecompilePreambleAfterNParses,
|
||||
&AST->FileMgr->getVirtualFileSystem()))
|
||||
AST->FileMgr->getVirtualFileSystemPtr()))
|
||||
return nullptr;
|
||||
return AST;
|
||||
}
|
||||
@ -1895,7 +1895,7 @@ bool ASTUnit::Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
|
||||
|
||||
if (!VFS) {
|
||||
assert(FileMgr && "FileMgr is null on Reparse call");
|
||||
VFS = &FileMgr->getVirtualFileSystem();
|
||||
VFS = FileMgr->getVirtualFileSystemPtr();
|
||||
}
|
||||
|
||||
clearFileLevelDecls();
|
||||
@ -2321,7 +2321,8 @@ void ASTUnit::CodeComplete(
|
||||
std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer;
|
||||
if (Preamble && Line > 1 && hasSameUniqueID(File, OriginalSourceFile)) {
|
||||
OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
|
||||
PCHContainerOps, Inv, &FileMgr.getVirtualFileSystem(), false, Line - 1);
|
||||
PCHContainerOps, Inv, FileMgr.getVirtualFileSystemPtr(), false,
|
||||
Line - 1);
|
||||
}
|
||||
|
||||
// If the main file has been overridden due to the use of a preamble,
|
||||
@ -2331,7 +2332,7 @@ void ASTUnit::CodeComplete(
|
||||
"No preamble was built, but OverrideMainBuffer is not null");
|
||||
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
|
||||
&FileMgr.getVirtualFileSystem();
|
||||
FileMgr.getVirtualFileSystemPtr();
|
||||
Preamble->AddImplicitPreamble(Clang->getInvocation(), VFS,
|
||||
OverrideMainBuffer.get());
|
||||
// FIXME: there is no way to update VFS if it was changed by
|
||||
|
@ -160,6 +160,11 @@ llvm::vfs::FileSystem &CompilerInstance::getVirtualFileSystem() const {
|
||||
return getFileManager().getVirtualFileSystem();
|
||||
}
|
||||
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
|
||||
CompilerInstance::getVirtualFileSystemPtr() const {
|
||||
return getFileManager().getVirtualFileSystemPtr();
|
||||
}
|
||||
|
||||
void CompilerInstance::setFileManager(FileManager *Value) {
|
||||
FileMgr = Value;
|
||||
}
|
||||
@ -375,7 +380,7 @@ IntrusiveRefCntPtr<DiagnosticsEngine> CompilerInstance::createDiagnostics(
|
||||
FileManager *CompilerInstance::createFileManager(
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
|
||||
if (!VFS)
|
||||
VFS = FileMgr ? &FileMgr->getVirtualFileSystem()
|
||||
VFS = FileMgr ? FileMgr->getVirtualFileSystemPtr()
|
||||
: createVFSFromCompilerInvocation(getInvocation(),
|
||||
getDiagnostics());
|
||||
assert(VFS && "FileManager has no VFS?");
|
||||
@ -1218,7 +1223,7 @@ std::unique_ptr<CompilerInstance> CompilerInstance::cloneForModuleCompileImpl(
|
||||
} else if (FrontendOpts.ModulesShareFileManager) {
|
||||
Instance.setFileManager(&getFileManager());
|
||||
} else {
|
||||
Instance.createFileManager(&getVirtualFileSystem());
|
||||
Instance.createFileManager(getVirtualFileSystemPtr());
|
||||
}
|
||||
|
||||
if (ThreadSafeConfig) {
|
||||
|
@ -57,11 +57,9 @@ createVFSOverlayForPreamblePCH(StringRef PCHFilename,
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
|
||||
// We want only the PCH file from the real filesystem to be available,
|
||||
// so we create an in-memory VFS with just that and overlay it on top.
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> PCHFS(
|
||||
new llvm::vfs::InMemoryFileSystem());
|
||||
auto PCHFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
PCHFS->addFile(PCHFilename, 0, std::move(PCHBuffer));
|
||||
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> Overlay(
|
||||
new llvm::vfs::OverlayFileSystem(VFS));
|
||||
auto Overlay = llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(VFS);
|
||||
Overlay->pushOverlay(PCHFS);
|
||||
return Overlay;
|
||||
}
|
||||
|
@ -581,8 +581,8 @@ llvm::Expected<std::string> applyAllReplacements(StringRef Code,
|
||||
if (Replaces.empty())
|
||||
return Code.str();
|
||||
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
|
||||
DiagnosticOptions DiagOpts;
|
||||
DiagnosticsEngine Diagnostics(
|
||||
|
@ -605,8 +605,8 @@ DependencyScanningWorker::DependencyScanningWorker(
|
||||
|
||||
switch (Service.getMode()) {
|
||||
case ScanningMode::DependencyDirectivesScan:
|
||||
DepFS =
|
||||
new DependencyScanningWorkerFilesystem(Service.getSharedCache(), FS);
|
||||
DepFS = llvm::makeIntrusiveRefCnt<DependencyScanningWorkerFilesystem>(
|
||||
Service.getSharedCache(), FS);
|
||||
BaseFS = DepFS;
|
||||
break;
|
||||
case ScanningMode::CanonicalPreprocessing:
|
||||
|
@ -227,10 +227,11 @@ bool runToolOnCodeWithArgs(
|
||||
const Twine &ToolName,
|
||||
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
|
||||
const FileContentMappings &VirtualMappedFiles) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
|
||||
SmallString<1024> CodeStorage;
|
||||
@ -403,7 +404,7 @@ bool ToolInvocation::run() {
|
||||
}
|
||||
|
||||
const std::unique_ptr<driver::Driver> Driver(
|
||||
newDriver(&*Diagnostics, BinaryName, &Files->getVirtualFileSystem()));
|
||||
newDriver(&*Diagnostics, BinaryName, Files->getVirtualFileSystemPtr()));
|
||||
// The "input file not found" diagnostics from the driver are useful.
|
||||
// The driver is only aware of the VFS working directory, but some clients
|
||||
// change this at the FileManager level instead.
|
||||
@ -473,8 +474,10 @@ ClangTool::ClangTool(const CompilationDatabase &Compilations,
|
||||
IntrusiveRefCntPtr<FileManager> Files)
|
||||
: Compilations(Compilations), SourcePaths(SourcePaths),
|
||||
PCHContainerOps(std::move(PCHContainerOps)),
|
||||
OverlayFileSystem(new llvm::vfs::OverlayFileSystem(std::move(BaseFS))),
|
||||
InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
|
||||
OverlayFileSystem(llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
std::move(BaseFS))),
|
||||
InMemoryFileSystem(
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
Files(Files ? Files
|
||||
: new FileManager(FileSystemOptions(), OverlayFileSystem)) {
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
@ -692,10 +695,11 @@ std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
|
||||
std::vector<std::unique_ptr<ASTUnit>> ASTs;
|
||||
ASTBuilderAction Action(ASTs);
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(std::move(BaseFS)));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
std::move(BaseFS));
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
|
@ -237,8 +237,8 @@ static bool parseLineRange(StringRef Input, unsigned &FromLine,
|
||||
|
||||
static bool fillRanges(MemoryBuffer *Code,
|
||||
std::vector<tooling::Range> &Ranges) {
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
|
||||
DiagnosticOptions DiagOpts;
|
||||
DiagnosticsEngine Diagnostics(
|
||||
@ -511,8 +511,8 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) {
|
||||
if (OutputXML) {
|
||||
outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
|
||||
} else {
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FileManager Files(FileSystemOptions(), InMemoryFileSystem);
|
||||
|
||||
DiagnosticOptions DiagOpts;
|
||||
|
@ -236,7 +236,7 @@ std::unique_ptr<CodeGenerator> BuildCodeGen(CompilerInstance &CI,
|
||||
llvm::LLVMContext &LLVMCtx) {
|
||||
StringRef ModuleName("$__module");
|
||||
return std::unique_ptr<CodeGenerator>(CreateLLVMCodeGen(
|
||||
CI.getDiagnostics(), ModuleName, &CI.getVirtualFileSystem(),
|
||||
CI.getDiagnostics(), ModuleName, CI.getVirtualFileSystemPtr(),
|
||||
CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
|
||||
LLVMCtx));
|
||||
}
|
||||
|
@ -83,10 +83,11 @@ static bool run(ArrayRef<const char *> Args, const char *ProgName) {
|
||||
|
||||
// Create file manager for all file operations and holding in-memory generated
|
||||
// inputs.
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
IntrusiveRefCntPtr<clang::FileManager> FM(
|
||||
new FileManager(clang::FileSystemOptions(), OverlayFileSystem));
|
||||
|
@ -33,7 +33,8 @@ namespace {
|
||||
class MacroExpansionContextTest : public ::testing::Test {
|
||||
protected:
|
||||
MacroExpansionContextTest()
|
||||
: InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
|
||||
: InMemoryFileSystem(
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
FileMgr(FileSystemOptions(), InMemoryFileSystem),
|
||||
DiagID(new DiagnosticIDs()),
|
||||
Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
|
||||
|
@ -454,8 +454,7 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
|
||||
: StringRef("/");
|
||||
llvm::sys::path::append(CustomWorkingDir, "some", "weird", "path");
|
||||
|
||||
auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
// setCurrentworkingdirectory must finish without error.
|
||||
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
|
||||
|
||||
@ -475,8 +474,7 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
|
||||
TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) {
|
||||
SmallString<64> CustomWorkingDir = getSystemRoot();
|
||||
|
||||
auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
// setCurrentworkingdirectory must finish without error.
|
||||
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
|
||||
|
||||
@ -501,8 +499,7 @@ TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) {
|
||||
TEST_F(FileManagerTest, getFileDontOpenRealPath) {
|
||||
SmallString<64> CustomWorkingDir = getSystemRoot();
|
||||
|
||||
auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
// setCurrentworkingdirectory must finish without error.
|
||||
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
|
||||
|
||||
@ -533,8 +530,7 @@ TEST_F(FileManagerTest, getBypassFile) {
|
||||
CustomWorkingDir = "/";
|
||||
#endif
|
||||
|
||||
auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
// setCurrentworkingdirectory must finish without error.
|
||||
ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir));
|
||||
|
||||
|
@ -41,7 +41,8 @@ static std::string serializeSarifDocument(llvm::json::Object &&Doc) {
|
||||
class SarifDocumentWriterTest : public ::testing::Test {
|
||||
protected:
|
||||
SarifDocumentWriterTest()
|
||||
: InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
|
||||
: InMemoryFileSystem(
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
FileMgr(FileSystemOptions(), InMemoryFileSystem),
|
||||
DiagID(new DiagnosticIDs()),
|
||||
Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
|
||||
|
@ -58,7 +58,7 @@ struct TestCompiler {
|
||||
|
||||
CG.reset(CreateLLVMCodeGen(
|
||||
compiler.getDiagnostics(), "main-module",
|
||||
&compiler.getVirtualFileSystem(), compiler.getHeaderSearchOpts(),
|
||||
compiler.getVirtualFileSystemPtr(), compiler.getHeaderSearchOpts(),
|
||||
compiler.getPreprocessorOpts(), compiler.getCodeGenOpts(), Context));
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,8 @@ static void validateTargetProfile(
|
||||
TEST(DxcModeTest, TargetProfileValidation) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
InMemoryFileSystem->addFile("foo.hlsl", 0,
|
||||
llvm::MemoryBuffer::getMemBuffer("\n"));
|
||||
@ -107,8 +107,8 @@ TEST(DxcModeTest, TargetProfileValidation) {
|
||||
TEST(DxcModeTest, ValidatorVersionValidation) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
InMemoryFileSystem->addFile("foo.hlsl", 0,
|
||||
llvm::MemoryBuffer::getMemBuffer("\n"));
|
||||
@ -210,8 +210,8 @@ TEST(DxcModeTest, ValidatorVersionValidation) {
|
||||
}
|
||||
|
||||
TEST(DxcModeTest, DefaultEntry) {
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
InMemoryFileSystem->addFile("foo.hlsl", 0,
|
||||
llvm::MemoryBuffer::getMemBuffer("\n"));
|
||||
|
@ -78,8 +78,7 @@ protected:
|
||||
private:
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>
|
||||
prepareFS(llvm::ArrayRef<std::string> ExtraFiles) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
|
||||
new llvm::vfs::InMemoryFileSystem;
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FS->addFile(ClangBinary, time_t(), llvm::MemoryBuffer::getMemBuffer(""));
|
||||
FS->addFile(InputFile, time_t(), llvm::MemoryBuffer::getMemBuffer(""));
|
||||
for (llvm::StringRef F : ExtraFiles)
|
||||
|
@ -44,8 +44,8 @@ struct SimpleDiagnosticConsumer : public clang::DiagnosticConsumer {
|
||||
inline clang::driver::Driver diagnostic_test_driver() {
|
||||
llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> DiagID(
|
||||
new clang::DiagnosticIDs());
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
auto *DiagConsumer = new SimpleDiagnosticConsumer;
|
||||
clang::DiagnosticOptions DiagOpts;
|
||||
clang::DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer);
|
||||
|
@ -42,8 +42,8 @@ TEST(ToolChainTest, VFSGCCInstallation) {
|
||||
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
const char *EmptyFiles[] = {
|
||||
"foo.cpp",
|
||||
@ -140,8 +140,8 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
|
||||
"clang LLVM compiler", InMemoryFileSystem);
|
||||
|
||||
@ -178,8 +178,8 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
|
||||
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
const char *EmptyFiles[] = {
|
||||
// Sort entries so the latest version doesn't come first.
|
||||
@ -342,8 +342,8 @@ TEST(ToolChainTest, VFSGnuLibcxxPathNoSysroot) {
|
||||
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
const char *EmptyFiles[] = {
|
||||
"foo.cpp",
|
||||
@ -374,8 +374,8 @@ TEST(ToolChainTest, DefaultDriverMode) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
|
||||
"clang LLVM compiler", InMemoryFileSystem);
|
||||
@ -520,8 +520,8 @@ TEST(ToolChainTest, CommandOutput) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
|
||||
"clang LLVM compiler", InMemoryFileSystem);
|
||||
@ -548,8 +548,8 @@ TEST(ToolChainTest, PostCallback) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
// The executable path must not exist.
|
||||
Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
|
||||
@ -601,8 +601,8 @@ TEST(ToolChainTest, UEFIDefaultDebugFormatTest) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
Driver CCDriver("/home/test/bin/clang", "x86_64-unknown-uefi", Diags,
|
||||
"clang LLVM compiler", InMemoryFileSystem);
|
||||
CCDriver.setCheckInputsExist(false);
|
||||
@ -643,8 +643,7 @@ TEST(ToolChainTest, ConfigFileSearch) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
#ifdef _WIN32
|
||||
const char *TestRoot = "C:\\";
|
||||
@ -721,7 +720,7 @@ TEST(ToolChainTest, ConfigFileError) {
|
||||
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
|
||||
new SimpleDiagnosticConsumer());
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS(new FileSystemWithError);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<FileSystemWithError>();
|
||||
|
||||
Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
|
||||
"clang LLVM compiler", FS);
|
||||
@ -742,8 +741,7 @@ TEST(ToolChainTest, BadConfigFile) {
|
||||
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
|
||||
new SimpleDiagnosticConsumer());
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
#ifdef _WIN32
|
||||
const char *TestRoot = "C:\\";
|
||||
@ -816,8 +814,7 @@ TEST(ToolChainTest, ConfigInexistentInclude) {
|
||||
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
|
||||
new SimpleDiagnosticConsumer());
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
#ifdef _WIN32
|
||||
const char *TestRoot = "C:\\";
|
||||
@ -857,8 +854,7 @@ TEST(ToolChainTest, ConfigRecursiveInclude) {
|
||||
std::unique_ptr<SimpleDiagnosticConsumer> DiagConsumer(
|
||||
new SimpleDiagnosticConsumer());
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, DiagConsumer.get(), false);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
#ifdef _WIN32
|
||||
const char *TestRoot = "C:\\";
|
||||
@ -902,8 +898,7 @@ TEST(ToolChainTest, NestedConfigFile) {
|
||||
IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
|
||||
struct TestDiagnosticConsumer : public DiagnosticConsumer {};
|
||||
DiagnosticsEngine Diags(DiagID, DiagOpts, new TestDiagnosticConsumer);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
|
||||
#ifdef _WIN32
|
||||
const char *TestRoot = "C:\\";
|
||||
|
@ -119,8 +119,7 @@ TEST_F(ASTUnitTest, GetBufferForFileMemoryMapping) {
|
||||
}
|
||||
|
||||
TEST_F(ASTUnitTest, ModuleTextualHeader) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFs =
|
||||
new llvm::vfs::InMemoryFileSystem();
|
||||
auto InMemoryFs = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
InMemoryFs->addFile("test.cpp", 0, llvm::MemoryBuffer::getMemBuffer(R"cpp(
|
||||
#include "Textual.h"
|
||||
void foo() {}
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
void TearDown() override {}
|
||||
|
||||
void ResetVFS() {
|
||||
VFS = new ReadCountingInMemoryFileSystem();
|
||||
VFS = llvm::makeIntrusiveRefCnt<ReadCountingInMemoryFileSystem>();
|
||||
// We need the working directory to be set to something absolute,
|
||||
// otherwise it ends up being inadvertently set to the current
|
||||
// working directory in the real file system due to a series of
|
||||
|
@ -28,7 +28,9 @@ class ReparseWorkingDirTest : public ::testing::Test {
|
||||
std::shared_ptr<PCHContainerOperations> PCHContainerOpts;
|
||||
|
||||
public:
|
||||
void SetUp() override { VFS = new vfs::InMemoryFileSystem(); }
|
||||
void SetUp() override {
|
||||
VFS = llvm::makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
}
|
||||
void TearDown() override {}
|
||||
|
||||
void setWorkingDirectory(StringRef Path) {
|
||||
|
@ -41,7 +41,7 @@ class SearchPathTest : public ::testing::Test {
|
||||
protected:
|
||||
SearchPathTest()
|
||||
: Diags(new DiagnosticIDs(), DiagOpts, new IgnoringDiagConsumer()),
|
||||
VFS(new llvm::vfs::InMemoryFileSystem),
|
||||
VFS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
FileMgr(FileSystemOptions(), VFS), SourceMgr(Diags, FileMgr),
|
||||
Invocation(std::make_unique<CompilerInvocation>()) {}
|
||||
|
||||
|
@ -29,7 +29,7 @@ TEST(BuildCompilerInvocationTest, RecoverMultipleJobs) {
|
||||
clang::DiagnosticOptions DiagOpts;
|
||||
CreateInvocationOptions Opts;
|
||||
Opts.RecoverOnError = true;
|
||||
Opts.VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
Opts.VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
Opts.Diags = clang::CompilerInstance::createDiagnostics(*Opts.VFS, DiagOpts,
|
||||
&D, false);
|
||||
std::unique_ptr<CompilerInvocation> CI = createInvocation(Args, Opts);
|
||||
|
@ -28,8 +28,8 @@ namespace {
|
||||
class HeaderSearchTest : public ::testing::Test {
|
||||
protected:
|
||||
HeaderSearchTest()
|
||||
: VFS(new llvm::vfs::InMemoryFileSystem), FileMgr(FileMgrOpts, VFS),
|
||||
DiagID(new DiagnosticIDs()),
|
||||
: VFS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
FileMgr(FileMgrOpts, VFS), DiagID(new DiagnosticIDs()),
|
||||
Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
|
||||
SourceMgr(Diags, FileMgr), TargetOpts(new TargetOptions),
|
||||
Search(HSOpts, SourceMgr, Diags, LangOpts, Target.get()) {
|
||||
|
@ -133,7 +133,8 @@ public:
|
||||
class PPCallbacksTest : public ::testing::Test {
|
||||
protected:
|
||||
PPCallbacksTest()
|
||||
: InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
|
||||
: InMemoryFileSystem(
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
FileMgr(FileSystemOptions(), InMemoryFileSystem),
|
||||
DiagID(new DiagnosticIDs()),
|
||||
Diags(DiagID, DiagOpts, new IgnoringDiagConsumer()),
|
||||
|
@ -75,7 +75,7 @@ TEST_F(PPDependencyDirectivesTest, MacroGuard) {
|
||||
// "head2.h" and "head3.h" have tokens following the macro check, they should
|
||||
// be included multiple times.
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->addFile(
|
||||
"head1.h", 0,
|
||||
llvm::MemoryBuffer::getMemBuffer("#ifndef H1_H\n#define H1_H\n#endif\n"));
|
||||
|
@ -46,8 +46,7 @@ std::string teardownProfiler() {
|
||||
bool compileFromString(StringRef Code, StringRef Standard, StringRef File,
|
||||
llvm::StringMap<std::string> Headers = {}) {
|
||||
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS(
|
||||
new llvm::vfs::InMemoryFileSystem());
|
||||
auto FS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FS->addFile(File, 0, MemoryBuffer::getMemBuffer(Code));
|
||||
for (const auto &Header : Headers) {
|
||||
FS->addFile(Header.getKey(), 0,
|
||||
|
@ -971,7 +971,8 @@ TEST_F(TargetAndModeTest, TargetAndMode) {
|
||||
|
||||
class ExpandResponseFilesTest : public MemDBTest {
|
||||
public:
|
||||
ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
|
||||
ExpandResponseFilesTest()
|
||||
: FS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()) {}
|
||||
|
||||
protected:
|
||||
void addFile(StringRef File, StringRef Content) {
|
||||
|
@ -85,7 +85,7 @@ TEST(DependencyScanner, ScanDepsReuseFilemanager) {
|
||||
StringRef CWD = "/root";
|
||||
FixedCompilationDatabase CDB(CWD, Compilation);
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->setCurrentWorkingDirectory(CWD);
|
||||
auto Sept = llvm::sys::path::get_separator();
|
||||
std::string HeaderPath =
|
||||
@ -134,7 +134,7 @@ TEST(DependencyScanner, ScanDepsReuseFilemanagerSkippedFile) {
|
||||
StringRef CWD = "/root";
|
||||
FixedCompilationDatabase CDB(CWD, Compilation);
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->setCurrentWorkingDirectory(CWD);
|
||||
auto Sept = llvm::sys::path::get_separator();
|
||||
std::string HeaderPath =
|
||||
@ -176,7 +176,7 @@ TEST(DependencyScanner, ScanDepsReuseFilemanagerHasInclude) {
|
||||
StringRef CWD = "/root";
|
||||
FixedCompilationDatabase CDB(CWD, Compilation);
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->setCurrentWorkingDirectory(CWD);
|
||||
auto Sept = llvm::sys::path::get_separator();
|
||||
std::string HeaderPath =
|
||||
@ -218,7 +218,7 @@ TEST(DependencyScanner, ScanDepsWithFS) {
|
||||
"test.cpp.o"};
|
||||
StringRef CWD = "/root";
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->setCurrentWorkingDirectory(CWD);
|
||||
auto Sept = llvm::sys::path::get_separator();
|
||||
std::string HeaderPath =
|
||||
@ -256,7 +256,7 @@ TEST(DependencyScanner, ScanDepsWithModuleLookup) {
|
||||
};
|
||||
StringRef CWD = "/root";
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->setCurrentWorkingDirectory(CWD);
|
||||
auto Sept = llvm::sys::path::get_separator();
|
||||
std::string OtherPath =
|
||||
@ -306,7 +306,7 @@ TEST(DependencyScanner, ScanDepsWithModuleLookup) {
|
||||
TEST(DependencyScanner, ScanDepsWithDiagConsumer) {
|
||||
StringRef CWD = "/root";
|
||||
|
||||
auto VFS = new llvm::vfs::InMemoryFileSystem();
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
VFS->setCurrentWorkingDirectory(CWD);
|
||||
auto Sept = llvm::sys::path::get_separator();
|
||||
std::string HeaderPath =
|
||||
|
@ -1035,8 +1035,7 @@ static constexpr bool usesWindowsPaths() {
|
||||
|
||||
TEST(DeduplicateByFileTest, PathsWithDots) {
|
||||
std::map<std::string, Replacements> FileToReplaces;
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
|
||||
new llvm::vfs::InMemoryFileSystem());
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FileManager FileMgr(FileSystemOptions(), VFS);
|
||||
StringRef Path1 = usesWindowsPaths() ? "a\\b\\..\\.\\c.h" : "a/b/.././c.h";
|
||||
StringRef Path2 = usesWindowsPaths() ? "a\\c.h" : "a/c.h";
|
||||
@ -1051,8 +1050,7 @@ TEST(DeduplicateByFileTest, PathsWithDots) {
|
||||
|
||||
TEST(DeduplicateByFileTest, PathWithDotSlash) {
|
||||
std::map<std::string, Replacements> FileToReplaces;
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
|
||||
new llvm::vfs::InMemoryFileSystem());
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FileManager FileMgr(FileSystemOptions(), VFS);
|
||||
StringRef Path1 = usesWindowsPaths() ? ".\\a\\b\\c.h" : "./a/b/c.h";
|
||||
StringRef Path2 = usesWindowsPaths() ? "a\\b\\c.h" : "a/b/c.h";
|
||||
@ -1067,8 +1065,7 @@ TEST(DeduplicateByFileTest, PathWithDotSlash) {
|
||||
|
||||
TEST(DeduplicateByFileTest, NonExistingFilePath) {
|
||||
std::map<std::string, Replacements> FileToReplaces;
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> VFS(
|
||||
new llvm::vfs::InMemoryFileSystem());
|
||||
auto VFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
FileManager FileMgr(FileSystemOptions(), VFS);
|
||||
StringRef Path1 = usesWindowsPaths() ? ".\\a\\b\\c.h" : "./a/b/c.h";
|
||||
StringRef Path2 = usesWindowsPaths() ? "a\\b\\c.h" : "a/b/c.h";
|
||||
|
@ -51,9 +51,11 @@ class RewriterTestContext {
|
||||
RewriterTestContext()
|
||||
: Diagnostics(IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs),
|
||||
DiagOpts),
|
||||
InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
|
||||
InMemoryFileSystem(
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())),
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem())),
|
||||
Files(FileSystemOptions(), OverlayFileSystem),
|
||||
Sources(Diagnostics, Files), Rewrite(Sources, Options) {
|
||||
Diagnostics.setClient(&DiagnosticPrinter, false);
|
||||
|
@ -252,7 +252,7 @@ public:
|
||||
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
|
||||
new DiagnosticsEngine(new DiagnosticIDs, DiagOpts);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
|
||||
new llvm::vfs::InMemoryFileSystem;
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
llvm::IntrusiveRefCntPtr<FileManager> FileMgr =
|
||||
new FileManager(FileSystemOptions(), FS);
|
||||
llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr =
|
||||
|
@ -44,7 +44,7 @@ protected:
|
||||
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
|
||||
new DiagnosticsEngine(new DiagnosticIDs, DiagOpts);
|
||||
IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> FS =
|
||||
new llvm::vfs::InMemoryFileSystem;
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
IntrusiveRefCntPtr<FileManager> FileMgr =
|
||||
new FileManager(FileSystemOptions(), FS);
|
||||
IntrusiveRefCntPtr<SourceManager> SourceMgr =
|
||||
|
@ -153,8 +153,8 @@ TEST(buildASTFromCode, ReportsErrors) {
|
||||
}
|
||||
|
||||
TEST(buildASTFromCode, FileSystem) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
InMemoryFileSystem->addFile("included_file.h", 0,
|
||||
llvm::MemoryBuffer::getMemBufferCopy("class X;"));
|
||||
std::unique_ptr<ASTUnit> AST = buildASTFromCodeWithArgs(
|
||||
@ -188,10 +188,11 @@ TEST(newFrontendActionFactory, CreatesFrontendActionFactoryFromFactoryType) {
|
||||
}
|
||||
|
||||
TEST(ToolInvocation, TestMapVirtualFile) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -214,10 +215,11 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) {
|
||||
// mapped module.modulemap is found on the include path. In the future, expand
|
||||
// this test to run a full modules enabled compilation, so we make sure we can
|
||||
// rerun modules compilations with a virtual file system.
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -240,10 +242,11 @@ TEST(ToolInvocation, TestVirtualModulesCompilation) {
|
||||
}
|
||||
|
||||
TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -269,10 +272,11 @@ TEST(ToolInvocation, DiagnosticsEngineProperlyInitializedForCC1Construction) {
|
||||
}
|
||||
|
||||
TEST(ToolInvocation, CustomDiagnosticOptionsOverwriteParsedOnes) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -315,10 +319,11 @@ struct DiagnosticConsumerExpectingSourceManager : public DiagnosticConsumer {
|
||||
};
|
||||
|
||||
TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -341,10 +346,11 @@ TEST(ToolInvocation, DiagConsumerExpectingSourceManager) {
|
||||
}
|
||||
|
||||
TEST(ToolInvocation, CC1Args) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -361,10 +367,11 @@ TEST(ToolInvocation, CC1Args) {
|
||||
}
|
||||
|
||||
TEST(ToolInvocation, CC1ArgsInvalid) {
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
llvm::IntrusiveRefCntPtr<FileManager> Files(
|
||||
new FileManager(FileSystemOptions(), OverlayFileSystem));
|
||||
@ -398,7 +405,7 @@ struct CommandLineExtractorTest : public ::testing::Test {
|
||||
|
||||
public:
|
||||
CommandLineExtractorTest()
|
||||
: InMemoryFS(new llvm::vfs::InMemoryFileSystem),
|
||||
: InMemoryFS(llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
|
||||
Diags(CompilerInstance::createDiagnostics(*InMemoryFS, DiagOpts)),
|
||||
Driver("clang", llvm::sys::getDefaultTargetTriple(), *Diags,
|
||||
"clang LLVM compiler", overlayRealFS(InMemoryFS)) {}
|
||||
@ -755,10 +762,11 @@ TEST(ClangToolTest, NoOutputCommands) {
|
||||
|
||||
TEST(ClangToolTest, BaseVirtualFileSystemUsage) {
|
||||
FixedCompilationDatabase Compilations("/", std::vector<std::string>());
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
|
||||
new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem()));
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem(
|
||||
new llvm::vfs::InMemoryFileSystem);
|
||||
auto OverlayFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
|
||||
llvm::vfs::getRealFileSystem());
|
||||
auto InMemoryFileSystem =
|
||||
llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
|
||||
OverlayFileSystem->pushOverlay(InMemoryFileSystem);
|
||||
|
||||
InMemoryFileSystem->addFile(
|
||||
|
@ -894,7 +894,7 @@ ClangExpressionParser::ClangExpressionParser(
|
||||
m_llvm_context = std::make_unique<LLVMContext>();
|
||||
m_code_generator.reset(CreateLLVMCodeGen(
|
||||
m_compiler->getDiagnostics(), module_name,
|
||||
&m_compiler->getVirtualFileSystem(), m_compiler->getHeaderSearchOpts(),
|
||||
m_compiler->getVirtualFileSystemPtr(), m_compiler->getHeaderSearchOpts(),
|
||||
m_compiler->getPreprocessorOpts(), m_compiler->getCodeGenOpts(),
|
||||
*m_llvm_context));
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ TEST(FileSystemTest, FileAndDirectoryComponents) {
|
||||
}
|
||||
|
||||
static IntrusiveRefCntPtr<DummyFileSystem> GetSimpleDummyFS() {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> D(new DummyFileSystem());
|
||||
auto D = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
D->addRegularFile("/foo");
|
||||
D->addDirectory("/bar");
|
||||
D->addSymlink("/baz");
|
||||
|
@ -1069,7 +1069,7 @@ public:
|
||||
/// Redirect each of the remapped files from first to second.
|
||||
static std::unique_ptr<RedirectingFileSystem>
|
||||
create(ArrayRef<std::pair<std::string, std::string>> RemappedFiles,
|
||||
bool UseExternalNames, FileSystem &ExternalFS);
|
||||
bool UseExternalNames, IntrusiveRefCntPtr<FileSystem> ExternalFS);
|
||||
|
||||
ErrorOr<Status> status(const Twine &Path) override;
|
||||
bool exists(const Twine &Path) override;
|
||||
|
@ -313,5 +313,6 @@ private:
|
||||
IntrusiveRefCntPtr<vfs::FileSystem>
|
||||
FileCollector::createCollectorVFS(IntrusiveRefCntPtr<vfs::FileSystem> BaseFS,
|
||||
std::shared_ptr<FileCollector> Collector) {
|
||||
return new FileCollectorFileSystem(std::move(BaseFS), std::move(Collector));
|
||||
return makeIntrusiveRefCnt<FileCollectorFileSystem>(std::move(BaseFS),
|
||||
std::move(Collector));
|
||||
}
|
||||
|
@ -397,7 +397,8 @@ void RealFileSystem::printImpl(raw_ostream &OS, PrintType Type,
|
||||
}
|
||||
|
||||
IntrusiveRefCntPtr<FileSystem> vfs::getRealFileSystem() {
|
||||
static IntrusiveRefCntPtr<FileSystem> FS(new RealFileSystem(true));
|
||||
static IntrusiveRefCntPtr<FileSystem> FS =
|
||||
makeIntrusiveRefCnt<RealFileSystem>(true);
|
||||
return FS;
|
||||
}
|
||||
|
||||
@ -2217,9 +2218,9 @@ RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer,
|
||||
|
||||
std::unique_ptr<RedirectingFileSystem> RedirectingFileSystem::create(
|
||||
ArrayRef<std::pair<std::string, std::string>> RemappedFiles,
|
||||
bool UseExternalNames, FileSystem &ExternalFS) {
|
||||
bool UseExternalNames, llvm::IntrusiveRefCntPtr<FileSystem> ExternalFS) {
|
||||
std::unique_ptr<RedirectingFileSystem> FS(
|
||||
new RedirectingFileSystem(&ExternalFS));
|
||||
new RedirectingFileSystem(ExternalFS));
|
||||
FS->UseExternalNames = UseExternalNames;
|
||||
|
||||
StringMap<RedirectingFileSystem::Entry *> Entries;
|
||||
@ -2228,7 +2229,7 @@ std::unique_ptr<RedirectingFileSystem> RedirectingFileSystem::create(
|
||||
SmallString<128> From = StringRef(Mapping.first);
|
||||
SmallString<128> To = StringRef(Mapping.second);
|
||||
{
|
||||
auto EC = ExternalFS.makeAbsolute(From);
|
||||
auto EC = ExternalFS->makeAbsolute(From);
|
||||
(void)EC;
|
||||
assert(!EC && "Could not make absolute path");
|
||||
}
|
||||
@ -2250,7 +2251,7 @@ std::unique_ptr<RedirectingFileSystem> RedirectingFileSystem::create(
|
||||
}
|
||||
assert(Parent && "File without a directory?");
|
||||
{
|
||||
auto EC = ExternalFS.makeAbsolute(To);
|
||||
auto EC = ExternalFS->makeAbsolute(To);
|
||||
(void)EC;
|
||||
assert(!EC && "Could not make absolute path");
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ std::string getPosixPath(const Twine &S) {
|
||||
} // end anonymous namespace
|
||||
|
||||
TEST(VirtualFileSystemTest, StatusQueries) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> D(new DummyFileSystem());
|
||||
auto D = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
ErrorOr<vfs::Status> Status((std::error_code()));
|
||||
|
||||
D->addRegularFile("/foo");
|
||||
@ -265,11 +265,11 @@ TEST(VirtualFileSystemTest, StatusQueries) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, BaseOnlyOverlay) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> D(new DummyFileSystem());
|
||||
auto D = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
ErrorOr<vfs::Status> Status((std::error_code()));
|
||||
EXPECT_FALSE(Status = D->status("/foo"));
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(new vfs::OverlayFileSystem(D));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(D);
|
||||
EXPECT_FALSE(Status = O->status("/foo"));
|
||||
|
||||
D->addRegularFile("/foo");
|
||||
@ -283,13 +283,12 @@ TEST(VirtualFileSystemTest, BaseOnlyOverlay) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("/foo");
|
||||
Lower->addSymlink("/lower_link");
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
// Regular file.
|
||||
@ -312,11 +311,10 @@ TEST(VirtualFileSystemTest, GetRealPathInOverlay) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, OverlayFiles) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Base(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Top(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Base));
|
||||
auto Base = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Middle = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Top = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Base);
|
||||
O->pushOverlay(Middle);
|
||||
O->pushOverlay(Top);
|
||||
|
||||
@ -351,10 +349,9 @@ TEST(VirtualFileSystemTest, OverlayFiles) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, OverlayDirsNonMerged) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
Lower->addDirectory("/lower-only");
|
||||
@ -376,10 +373,9 @@ TEST(VirtualFileSystemTest, OverlayDirsNonMerged) {
|
||||
|
||||
TEST(VirtualFileSystemTest, MergedDirPermissions) {
|
||||
// merged directories get the permissions of the upper dir
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
ErrorOr<vfs::Status> Status((std::error_code()));
|
||||
@ -401,12 +397,11 @@ TEST(VirtualFileSystemTest, MergedDirPermissions) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, OverlayIterator) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("/foo");
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
ErrorOr<vfs::Status> Status((std::error_code()));
|
||||
@ -784,10 +779,9 @@ static void checkContents(DirIter I, ArrayRef<StringRef> ExpectedOut) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, OverlayIteration) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
std::error_code EC;
|
||||
@ -808,11 +802,10 @@ TEST(VirtualFileSystemTest, OverlayIteration) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, OverlayRecursiveIteration) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Middle = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Middle);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
@ -850,11 +843,10 @@ TEST(VirtualFileSystemTest, OverlayRecursiveIteration) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, ThreeLevelIteration) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Middle = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Middle);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
@ -870,11 +862,10 @@ TEST(VirtualFileSystemTest, ThreeLevelIteration) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, HiddenInIteration) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Middle = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Middle);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
@ -913,11 +904,10 @@ TEST(VirtualFileSystemTest, HiddenInIteration) {
|
||||
}
|
||||
|
||||
TEST(VirtualFileSystemTest, Visit) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Base(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Middle(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Top(new DummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Base));
|
||||
auto Base = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Middle = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto Top = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Base);
|
||||
O->pushOverlay(Middle);
|
||||
O->pushOverlay(Top);
|
||||
|
||||
@ -984,10 +974,9 @@ TEST(OverlayFileSystemTest, PrintOutput) {
|
||||
}
|
||||
|
||||
TEST(OverlayFileSystemTest, Exists) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new NoStatusDummyFileSystem());
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Upper(new NoStatusDummyFileSystem());
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto Lower = makeIntrusiveRefCnt<NoStatusDummyFileSystem>();
|
||||
auto Upper = makeIntrusiveRefCnt<NoStatusDummyFileSystem>();
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(Upper);
|
||||
|
||||
Lower->addDirectory("/both");
|
||||
@ -1008,8 +997,7 @@ TEST(OverlayFileSystemTest, Exists) {
|
||||
}
|
||||
|
||||
TEST(ProxyFileSystemTest, Basic) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> Base(
|
||||
new vfs::InMemoryFileSystem());
|
||||
auto Base = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
vfs::ProxyFileSystem PFS(Base);
|
||||
|
||||
Base->addFile("/a", 0, MemoryBuffer::getMemBuffer("test"));
|
||||
@ -1606,7 +1594,7 @@ TEST_F(VFSFromYAMLTest, BasicVFSFromYAML) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, MappedFiles) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/foo/bar");
|
||||
Lower->addRegularFile("//root/foo/bar/a");
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
|
||||
@ -1642,8 +1630,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
// file
|
||||
@ -1720,7 +1707,7 @@ TEST_F(VFSFromYAMLTest, MappedFiles) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, MappedRoot) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/foo/bar");
|
||||
Lower->addRegularFile("//root/foo/bar/a");
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS =
|
||||
@ -1735,8 +1722,7 @@ TEST_F(VFSFromYAMLTest, MappedRoot) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
// file
|
||||
@ -1762,7 +1748,7 @@ TEST_F(VFSFromYAMLTest, MappedRoot) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlay) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
Lower->addDirectory("//root/bar");
|
||||
@ -1783,8 +1769,7 @@ TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlay) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
ErrorOr<vfs::Status> S = O->status("//root/foo");
|
||||
@ -1806,7 +1791,7 @@ TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlay) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlayNoExternalNames) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
Lower->addDirectory("//root/bar");
|
||||
@ -1847,7 +1832,7 @@ TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlayNoExternalNames) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlayNoFallthrough) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
Lower->addDirectory("//root/bar");
|
||||
@ -1887,13 +1872,12 @@ TEST_F(VFSFromYAMLTest, RemappedDirectoryOverlayNoFallthrough) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> BaseFS(
|
||||
new vfs::InMemoryFileSystem);
|
||||
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
BaseFS->addFile("//root/foo/a", 0,
|
||||
MemoryBuffer::getMemBuffer("contents of a"));
|
||||
ASSERT_FALSE(BaseFS->setCurrentWorkingDirectory("//root/foo"));
|
||||
auto RemappedFS = vfs::RedirectingFileSystem::create(
|
||||
{}, /*UseExternalNames=*/false, *BaseFS);
|
||||
{}, /*UseExternalNames=*/false, BaseFS);
|
||||
|
||||
auto OpenedF = RemappedFS->openFileForRead("a");
|
||||
ASSERT_FALSE(OpenedF.getError());
|
||||
@ -1915,8 +1899,7 @@ TEST_F(VFSFromYAMLTest, ReturnsRequestedPathVFSMiss) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> BaseFS(
|
||||
new vfs::InMemoryFileSystem);
|
||||
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
BaseFS->addFile("//root/foo/realname", 0,
|
||||
MemoryBuffer::getMemBuffer("contents of a"));
|
||||
auto FS =
|
||||
@ -1955,7 +1938,7 @@ TEST_F(VFSFromYAMLTest, ReturnsExternalPathVFSHit) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RootRelativeTest) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/foo/bar");
|
||||
Lower->addRegularFile("//root/foo/bar/a");
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS =
|
||||
@ -1996,7 +1979,7 @@ TEST_F(VFSFromYAMLTest, RootRelativeTest) {
|
||||
ASSERT_FALSE(S.getError());
|
||||
EXPECT_EQ("//root/foo/bar/a", S->getName());
|
||||
#else
|
||||
IntrusiveRefCntPtr<DummyFileSystem> LowerWindows(new DummyFileSystem());
|
||||
auto LowerWindows = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
LowerWindows->addDirectory("\\\\root\\foo\\bar");
|
||||
LowerWindows->addRegularFile("\\\\root\\foo\\bar\\a");
|
||||
FS = getFromYAMLString("{\n"
|
||||
@ -2018,8 +2001,7 @@ TEST_F(VFSFromYAMLTest, RootRelativeTest) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> BaseFS(
|
||||
new vfs::InMemoryFileSystem);
|
||||
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
BaseFS->addFile("//root/foo/realname", 0,
|
||||
MemoryBuffer::getMemBuffer("contents of a"));
|
||||
auto FS =
|
||||
@ -2058,7 +2040,7 @@ TEST_F(VFSFromYAMLTest, ReturnsInternalPathVFSHit) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, CaseInsensitive) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("//root/foo/bar/a");
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
|
||||
"{ 'case-sensitive': 'false',\n"
|
||||
@ -2076,8 +2058,7 @@ TEST_F(VFSFromYAMLTest, CaseInsensitive) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
ErrorOr<vfs::Status> S = O->status("//root/XX");
|
||||
@ -2094,7 +2075,7 @@ TEST_F(VFSFromYAMLTest, CaseInsensitive) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, CaseSensitive) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("//root/foo/bar/a");
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString(
|
||||
"{ 'case-sensitive': 'true',\n"
|
||||
@ -2112,8 +2093,7 @@ TEST_F(VFSFromYAMLTest, CaseSensitive) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
ErrorOr<vfs::Status> SS = O->status("//root/xx");
|
||||
@ -2126,7 +2106,7 @@ TEST_F(VFSFromYAMLTest, CaseSensitive) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, IllegalVFSFile) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
|
||||
// invalid YAML at top-level
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLString("{]", Lower);
|
||||
@ -2252,7 +2232,7 @@ TEST_F(VFSFromYAMLTest, IllegalVFSFile) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, UseExternalName) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("//root/external/file");
|
||||
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS =
|
||||
@ -2304,7 +2284,7 @@ TEST_F(VFSFromYAMLTest, UseExternalName) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, MultiComponentPath) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("//root/other");
|
||||
|
||||
// file in roots
|
||||
@ -2350,7 +2330,7 @@ TEST_F(VFSFromYAMLTest, MultiComponentPath) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, TrailingSlashes) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addRegularFile("//root/other");
|
||||
|
||||
// file in roots
|
||||
@ -2369,7 +2349,7 @@ TEST_F(VFSFromYAMLTest, TrailingSlashes) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, DirectoryIteration) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addDirectory("//root/foo/bar");
|
||||
@ -2399,8 +2379,7 @@ TEST_F(VFSFromYAMLTest, DirectoryIteration) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
std::error_code EC;
|
||||
@ -2416,7 +2395,7 @@ TEST_F(VFSFromYAMLTest, DirectoryIterationSameDirMultipleEntries) {
|
||||
if (!supportsSameDirMultipleYAMLEntries())
|
||||
GTEST_SKIP();
|
||||
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/zab");
|
||||
Lower->addDirectory("//root/baz");
|
||||
Lower->addRegularFile("//root/zab/a");
|
||||
@ -2449,8 +2428,7 @@ TEST_F(VFSFromYAMLTest, DirectoryIterationSameDirMultipleEntries) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
std::error_code EC;
|
||||
@ -2461,7 +2439,7 @@ TEST_F(VFSFromYAMLTest, DirectoryIterationSameDirMultipleEntries) {
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RecursiveDirectoryIterationLevel) {
|
||||
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/a");
|
||||
Lower->addDirectory("//root/a/b");
|
||||
Lower->addDirectory("//root/a/b/c");
|
||||
@ -2484,8 +2462,7 @@ TEST_F(VFSFromYAMLTest, RecursiveDirectoryIterationLevel) {
|
||||
Lower);
|
||||
ASSERT_NE(FS.get(), nullptr);
|
||||
|
||||
IntrusiveRefCntPtr<vfs::OverlayFileSystem> O(
|
||||
new vfs::OverlayFileSystem(Lower));
|
||||
auto O = makeIntrusiveRefCnt<vfs::OverlayFileSystem>(Lower);
|
||||
O->pushOverlay(FS);
|
||||
|
||||
std::error_code EC;
|
||||
@ -2503,7 +2480,7 @@ TEST_F(VFSFromYAMLTest, RecursiveDirectoryIterationLevel) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RelativePaths) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
std::error_code EC;
|
||||
SmallString<128> CWD;
|
||||
EC = llvm::sys::fs::current_path(CWD);
|
||||
@ -2557,7 +2534,7 @@ TEST_F(VFSFromYAMLTest, RelativePaths) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, NonFallthroughDirectoryIteration) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addRegularFile("//root/a");
|
||||
Lower->addRegularFile("//root/b");
|
||||
@ -2586,7 +2563,7 @@ TEST_F(VFSFromYAMLTest, NonFallthroughDirectoryIteration) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, DirectoryIterationWithDuplicates) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addRegularFile("//root/a");
|
||||
Lower->addRegularFile("//root/b");
|
||||
@ -2614,7 +2591,7 @@ TEST_F(VFSFromYAMLTest, DirectoryIterationWithDuplicates) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, DirectoryIterationErrorInVFSLayer) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
@ -2643,7 +2620,7 @@ TEST_F(VFSFromYAMLTest, DirectoryIterationErrorInVFSLayer) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, GetRealPath) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//dir/");
|
||||
Lower->addRegularFile("/foo");
|
||||
Lower->addSymlink("/link");
|
||||
@ -2695,7 +2672,7 @@ TEST_F(VFSFromYAMLTest, GetRealPath) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, WorkingDirectory) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
@ -2753,7 +2730,7 @@ TEST_F(VFSFromYAMLTest, WorkingDirectory) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, WorkingDirectoryFallthrough) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Lower(new DummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
@ -2835,7 +2812,7 @@ TEST_F(VFSFromYAMLTest, WorkingDirectoryFallthrough) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, WorkingDirectoryFallthroughInvalid) {
|
||||
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<ErrorDummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
@ -2872,7 +2849,7 @@ TEST_F(VFSFromYAMLTest, WorkingDirectoryFallthroughInvalid) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, VirtualWorkingDirectory) {
|
||||
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<ErrorDummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/foo");
|
||||
Lower->addRegularFile("//root/foo/a");
|
||||
@ -2928,7 +2905,7 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest) {
|
||||
raw_string_ostream OS(Buffer);
|
||||
VFSWriter.write(OS);
|
||||
|
||||
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<ErrorDummyFileSystem>();
|
||||
Lower->addDirectory("//root/");
|
||||
Lower->addDirectory("//root/a");
|
||||
Lower->addRegularFile("//root/a/b");
|
||||
@ -2978,7 +2955,7 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest2) {
|
||||
raw_string_ostream OS(Buffer);
|
||||
VFSWriter.write(OS);
|
||||
|
||||
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<ErrorDummyFileSystem>();
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLRawString(Buffer, Lower);
|
||||
EXPECT_NE(FS.get(), nullptr);
|
||||
}
|
||||
@ -3010,7 +2987,7 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTest3) {
|
||||
raw_string_ostream OS(Buffer);
|
||||
VFSWriter.write(OS);
|
||||
|
||||
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<ErrorDummyFileSystem>();
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = getFromYAMLRawString(Buffer, Lower);
|
||||
EXPECT_NE(FS.get(), nullptr);
|
||||
}
|
||||
@ -3033,7 +3010,7 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTestHandleDirs) {
|
||||
// We didn't add a single file - only directories.
|
||||
EXPECT_EQ(Buffer.find("'type': 'file'"), std::string::npos);
|
||||
|
||||
IntrusiveRefCntPtr<ErrorDummyFileSystem> Lower(new ErrorDummyFileSystem());
|
||||
auto Lower = makeIntrusiveRefCnt<ErrorDummyFileSystem>();
|
||||
Lower->addDirectory("//root/a");
|
||||
Lower->addDirectory("//root/b");
|
||||
Lower->addDirectory("//root/c");
|
||||
@ -3051,17 +3028,17 @@ TEST_F(VFSFromYAMLTest, YAMLVFSWriterTestHandleDirs) {
|
||||
}
|
||||
|
||||
TEST_F(VFSFromYAMLTest, RedirectingWith) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Both(new DummyFileSystem());
|
||||
auto Both = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
Both->addDirectory("//root/a");
|
||||
Both->addRegularFile("//root/a/f");
|
||||
Both->addDirectory("//root/b");
|
||||
Both->addRegularFile("//root/b/f");
|
||||
|
||||
IntrusiveRefCntPtr<DummyFileSystem> AOnly(new DummyFileSystem());
|
||||
auto AOnly = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
AOnly->addDirectory("//root/a");
|
||||
AOnly->addRegularFile("//root/a/f");
|
||||
|
||||
IntrusiveRefCntPtr<DummyFileSystem> BOnly(new DummyFileSystem());
|
||||
auto BOnly = makeIntrusiveRefCnt<DummyFileSystem>();
|
||||
BOnly->addDirectory("//root/b");
|
||||
BOnly->addRegularFile("//root/b/f");
|
||||
|
||||
@ -3166,8 +3143,7 @@ TEST_F(VFSFromYAMLTest, RedirectingWith) {
|
||||
}
|
||||
|
||||
TEST(VFSFromRemappedFilesTest, Basic) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> BaseFS =
|
||||
new vfs::InMemoryFileSystem;
|
||||
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
BaseFS->addFile("//root/b", 0, MemoryBuffer::getMemBuffer("contents of b"));
|
||||
BaseFS->addFile("//root/c", 0, MemoryBuffer::getMemBuffer("contents of c"));
|
||||
|
||||
@ -3176,7 +3152,7 @@ TEST(VFSFromRemappedFilesTest, Basic) {
|
||||
{"//root/a/b/c", "//root/c"},
|
||||
};
|
||||
auto RemappedFS = vfs::RedirectingFileSystem::create(
|
||||
RemappedFiles, /*UseExternalNames=*/false, *BaseFS);
|
||||
RemappedFiles, /*UseExternalNames=*/false, BaseFS);
|
||||
|
||||
auto StatA = RemappedFS->status("//root/a/a");
|
||||
auto StatB = RemappedFS->status("//root/a/b/c");
|
||||
@ -3194,8 +3170,7 @@ TEST(VFSFromRemappedFilesTest, Basic) {
|
||||
}
|
||||
|
||||
TEST(VFSFromRemappedFilesTest, UseExternalNames) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> BaseFS =
|
||||
new vfs::InMemoryFileSystem;
|
||||
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
BaseFS->addFile("//root/b", 0, MemoryBuffer::getMemBuffer("contents of b"));
|
||||
BaseFS->addFile("//root/c", 0, MemoryBuffer::getMemBuffer("contents of c"));
|
||||
|
||||
@ -3204,7 +3179,7 @@ TEST(VFSFromRemappedFilesTest, UseExternalNames) {
|
||||
{"//root/a/b/c", "//root/c"},
|
||||
};
|
||||
auto RemappedFS = vfs::RedirectingFileSystem::create(
|
||||
RemappedFiles, /*UseExternalNames=*/true, *BaseFS);
|
||||
RemappedFiles, /*UseExternalNames=*/true, BaseFS);
|
||||
|
||||
auto StatA = RemappedFS->status("//root/a/a");
|
||||
auto StatB = RemappedFS->status("//root/a/b/c");
|
||||
@ -3222,8 +3197,7 @@ TEST(VFSFromRemappedFilesTest, UseExternalNames) {
|
||||
}
|
||||
|
||||
TEST(VFSFromRemappedFilesTest, LastMappingWins) {
|
||||
IntrusiveRefCntPtr<vfs::InMemoryFileSystem> BaseFS =
|
||||
new vfs::InMemoryFileSystem;
|
||||
auto BaseFS = makeIntrusiveRefCnt<vfs::InMemoryFileSystem>();
|
||||
BaseFS->addFile("//root/b", 0, MemoryBuffer::getMemBuffer("contents of b"));
|
||||
BaseFS->addFile("//root/c", 0, MemoryBuffer::getMemBuffer("contents of c"));
|
||||
|
||||
@ -3232,9 +3206,9 @@ TEST(VFSFromRemappedFilesTest, LastMappingWins) {
|
||||
{"//root/a", "//root/c"},
|
||||
};
|
||||
auto RemappedFSKeepName = vfs::RedirectingFileSystem::create(
|
||||
RemappedFiles, /*UseExternalNames=*/false, *BaseFS);
|
||||
RemappedFiles, /*UseExternalNames=*/false, BaseFS);
|
||||
auto RemappedFSExternalName = vfs::RedirectingFileSystem::create(
|
||||
RemappedFiles, /*UseExternalNames=*/true, *BaseFS);
|
||||
RemappedFiles, /*UseExternalNames=*/true, BaseFS);
|
||||
|
||||
auto StatKeepA = RemappedFSKeepName->status("//root/a");
|
||||
auto StatExternalA = RemappedFSExternalName->status("//root/a");
|
||||
@ -3416,7 +3390,7 @@ TEST(RedirectingFileSystemTest, ExternalPaths) {
|
||||
BaseFS->setCurrentWorkingDirectory("/cwd");
|
||||
auto CheckFS = makeIntrusiveRefCnt<InterceptorFS>(BaseFS);
|
||||
auto FS = vfs::RedirectingFileSystem::create({}, /*UseExternalNames=*/false,
|
||||
*CheckFS);
|
||||
CheckFS);
|
||||
|
||||
FS->status("/a/../b");
|
||||
FS->openFileForRead("c");
|
||||
@ -3442,7 +3416,7 @@ TEST(RedirectingFileSystemTest, ExternalPaths) {
|
||||
}
|
||||
|
||||
TEST(RedirectingFileSystemTest, Exists) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Dummy(new NoStatusDummyFileSystem());
|
||||
auto Dummy = makeIntrusiveRefCnt<NoStatusDummyFileSystem>();
|
||||
auto YAML =
|
||||
MemoryBuffer::getMemBuffer("{\n"
|
||||
" 'version': 0,\n"
|
||||
@ -3513,7 +3487,7 @@ TEST(RedirectingFileSystemTest, Exists) {
|
||||
}
|
||||
|
||||
TEST(RedirectingFileSystemTest, ExistsFallback) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Dummy(new NoStatusDummyFileSystem());
|
||||
auto Dummy = makeIntrusiveRefCnt<NoStatusDummyFileSystem>();
|
||||
auto YAML =
|
||||
MemoryBuffer::getMemBuffer("{\n"
|
||||
" 'version': 0,\n"
|
||||
@ -3537,7 +3511,7 @@ TEST(RedirectingFileSystemTest, ExistsFallback) {
|
||||
}
|
||||
|
||||
TEST(RedirectingFileSystemTest, ExistsRedirectOnly) {
|
||||
IntrusiveRefCntPtr<DummyFileSystem> Dummy(new NoStatusDummyFileSystem());
|
||||
auto Dummy = makeIntrusiveRefCnt<NoStatusDummyFileSystem>();
|
||||
auto YAML =
|
||||
MemoryBuffer::getMemBuffer("{\n"
|
||||
" 'version': 0,\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user