[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(). llvm-svn: 325132
This commit is contained in:
parent
cc6d29d72c
commit
12aa52fe22
|
@ -76,22 +76,6 @@ private:
|
||||||
VFSTag LastVFSTag = VFSTag();
|
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
|
/// Replaces all patterns of the form 0x123abc with spaces
|
||||||
std::string replacePtrsInDump(std::string const &Dump) {
|
std::string replacePtrsInDump(std::string const &Dump) {
|
||||||
llvm::Regex RE("0x[0-9a-fA-F]+");
|
llvm::Regex RE("0x[0-9a-fA-F]+");
|
||||||
|
@ -500,11 +484,10 @@ int d;
|
||||||
FilePaths.push_back(getVirtualTestFilePath(std::string("Foo") +
|
FilePaths.push_back(getVirtualTestFilePath(std::string("Foo") +
|
||||||
std::to_string(I) + ".cpp"));
|
std::to_string(I) + ".cpp"));
|
||||||
// Mark all of those files as existing.
|
// Mark all of those files as existing.
|
||||||
llvm::StringMap<std::string> FileContents;
|
MockFSProvider FS;
|
||||||
for (auto &&FilePath : FilePaths)
|
for (auto &&FilePath : FilePaths)
|
||||||
FileContents[FilePath] = "";
|
FS.Files[FilePath] = "";
|
||||||
|
|
||||||
ConstantFSProvider FS(buildTestFS(FileContents));
|
|
||||||
|
|
||||||
struct FileStat {
|
struct FileStat {
|
||||||
unsigned HitsWithoutErrors = 0;
|
unsigned HitsWithoutErrors = 0;
|
||||||
|
|
Loading…
Reference in New Issue