[clangd] Fixed crash on MacOS.

Caused by invalid order of members in ClangdServer.
DiagnosticsMutex was used after destruction.

llvm-svn: 313801
This commit is contained in:
Ilya Biryukov 2017-09-20 19:32:06 +00:00
parent 23be5e8d70
commit f4e95d7290
2 changed files with 5 additions and 6 deletions

View File

@ -151,7 +151,7 @@ ClangdServer::ClangdServer(GlobalCompilationDatabase &CDB,
FSProvider(FSProvider),
ResourceDir(ResourceDir ? ResourceDir->str() : getStandardResourceDir()),
PCHs(std::make_shared<PCHContainerOperations>()),
WorkScheduler(AsyncThreadsCount), SnippetCompletions(SnippetCompletions) {
SnippetCompletions(SnippetCompletions), WorkScheduler(AsyncThreadsCount) {
}
std::future<void> ClangdServer::addDocument(PathRef File, StringRef Contents) {

View File

@ -279,18 +279,17 @@ private:
CppFileCollection Units;
std::string ResourceDir;
std::shared_ptr<PCHContainerOperations> PCHs;
// WorkScheduler has to be the last member, because its destructor has to be
// called before all other members to stop the worker thread that references
// ClangdServer
ClangdScheduler WorkScheduler;
bool SnippetCompletions;
/// Used to serialize diagnostic callbacks.
/// FIXME(ibiryukov): get rid of an extra map and put all version counters
/// into CppFile.
std::mutex DiagnosticsMutex;
/// Maps from a filename to the latest version of reported diagnostics.
llvm::StringMap<DocVersion> ReportedDiagnosticVersions;
// WorkScheduler has to be the last member, because its destructor has to be
// called before all other members to stop the worker thread that references
// ClangdServer
ClangdScheduler WorkScheduler;
};
} // namespace clangd