diff options
author | Alex Lorenz <arphaman@gmail.com> | 2019-08-27 01:03:25 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2019-08-27 01:03:25 +0000 |
commit | 67d25fede9aa7be37b2dcd20e3402f3f190e41f9 (patch) | |
tree | 0169ec81b0d91d5982b84774f7c29f6ab5d12892 /clang/unittests/Tooling/DependencyScannerTest.cpp | |
parent | 228ffac6786a8719bfb1d0452f49ee49b0a6fc28 (diff) | |
download | bcm5719-llvm-67d25fede9aa7be37b2dcd20e3402f3f190e41f9.tar.gz bcm5719-llvm-67d25fede9aa7be37b2dcd20e3402f3f190e41f9.zip |
Use FileEntryRef for PPCallbacks::FileSkipped
This fixes the issue where a filename dependendency was missing if the file that
was skipped was included through a symlink in an earlier run, if the file
manager was reused between runs.
llvm-svn: 369998
Diffstat (limited to 'clang/unittests/Tooling/DependencyScannerTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/DependencyScannerTest.cpp | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/clang/unittests/Tooling/DependencyScannerTest.cpp b/clang/unittests/Tooling/DependencyScannerTest.cpp index 1ca9e12bf5c..458bb9e0174 100644 --- a/clang/unittests/Tooling/DependencyScannerTest.cpp +++ b/clang/unittests/Tooling/DependencyScannerTest.cpp @@ -37,7 +37,8 @@ public: : DependencyFileGenerator(Opts), Deps(Deps) {} void finishedMainFile(DiagnosticsEngine &Diags) override { - Deps = getDependencies(); + auto NewDeps = getDependencies(); + Deps.insert(Deps.end(), NewDeps.begin(), NewDeps.end()); } private: @@ -121,5 +122,44 @@ TEST(DependencyScanner, ScanDepsReuseFilemanager) { EXPECT_EQ(Files.getNumUniqueRealFiles(), 2u); } +TEST(DependencyScanner, ScanDepsReuseFilemanagerSkippedFile) { + std::vector<std::string> Compilation = {"-c", "-E", "-MT", "test.cpp.o"}; + StringRef CWD = "/root"; + FixedCompilationDatabase CDB(CWD, Compilation); + + auto VFS = new llvm::vfs::InMemoryFileSystem(); + VFS->setCurrentWorkingDirectory(CWD); + auto Sept = llvm::sys::path::get_separator(); + std::string HeaderPath = llvm::formatv("{0}root{0}header.h", Sept); + std::string SymlinkPath = llvm::formatv("{0}root{0}symlink.h", Sept); + std::string TestPath = llvm::formatv("{0}root{0}test.cpp", Sept); + std::string Test2Path = llvm::formatv("{0}root{0}test2.cpp", Sept); + + VFS->addFile(HeaderPath, 0, + llvm::MemoryBuffer::getMemBuffer("#pragma once\n")); + VFS->addHardLink(SymlinkPath, HeaderPath); + VFS->addFile(TestPath, 0, + llvm::MemoryBuffer::getMemBuffer( + "#include \"header.h\"\n#include \"symlink.h\"\n")); + VFS->addFile(Test2Path, 0, + llvm::MemoryBuffer::getMemBuffer( + "#include \"symlink.h\"\n#include \"header.h\"\n")); + + ClangTool Tool(CDB, {"test.cpp", "test2.cpp"}, + std::make_shared<PCHContainerOperations>(), VFS); + Tool.clearArgumentsAdjusters(); + std::vector<std::string> Deps; + TestDependencyScanningAction Action(Deps); + Tool.run(&Action); + using llvm::sys::path::convert_to_slash; + ASSERT_EQ(Deps.size(), 6u); + EXPECT_EQ(convert_to_slash(Deps[0]), "/root/test.cpp"); + EXPECT_EQ(convert_to_slash(Deps[1]), "/root/header.h"); + EXPECT_EQ(convert_to_slash(Deps[2]), "/root/symlink.h"); + EXPECT_EQ(convert_to_slash(Deps[3]), "/root/test2.cpp"); + EXPECT_EQ(convert_to_slash(Deps[4]), "/root/symlink.h"); + EXPECT_EQ(convert_to_slash(Deps[5]), "/root/header.h"); +} + } // end namespace tooling } // end namespace clang |