Author: ibiryukov Date: Wed Feb 14 07:19:20 2018 New Revision: 325132 URL: http://llvm.org/viewvc/llvm-project?rev=325132&view=rev Log: [clangd] Fix data race in ClangdThreadingTest.StressTest
Prior to this patch, same instance of VFS was shared for concurrent processing of the files in ClangdThreadingTest.StressTest. It caused a data race as the same instance of InMemoryFileSystem was mutated from multiple threads using setCurrentWorkingDirectory(). Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=325132&r1=325131&r2=325132&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Wed Feb 14 07:19:20 2018 @@ -76,22 +76,6 @@ private: VFSTag LastVFSTag = VFSTag(); }; -class ConstantFSProvider : public FileSystemProvider { -public: - ConstantFSProvider(IntrusiveRefCntPtr<vfs::FileSystem> FS, - VFSTag Tag = VFSTag()) - : FS(std::move(FS)), Tag(std::move(Tag)) {} - - Tagged<IntrusiveRefCntPtr<vfs::FileSystem>> - getTaggedFileSystem(PathRef File) override { - return make_tagged(FS, Tag); - } - -private: - IntrusiveRefCntPtr<vfs::FileSystem> FS; - VFSTag Tag; -}; - /// Replaces all patterns of the form 0x123abc with spaces std::string replacePtrsInDump(std::string const &Dump) { llvm::Regex RE("0x[0-9a-fA-F]+"); @@ -500,11 +484,10 @@ int d; FilePaths.push_back(getVirtualTestFilePath(std::string("Foo") + std::to_string(I) + ".cpp")); // Mark all of those files as existing. - llvm::StringMap<std::string> FileContents; + MockFSProvider FS; for (auto &&FilePath : FilePaths) - FileContents[FilePath] = ""; + FS.Files[FilePath] = ""; - ConstantFSProvider FS(buildTestFS(FileContents)); struct FileStat { unsigned HitsWithoutErrors = 0; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits