2017-05-16 17:38:59 +08:00
|
|
|
//===--- ClangdUnitStore.cpp - A ClangdUnits container -----------*-C++-*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "ClangdUnitStore.h"
|
|
|
|
#include "llvm/Support/Path.h"
|
2017-08-14 16:37:32 +08:00
|
|
|
#include <algorithm>
|
2017-05-16 17:38:59 +08:00
|
|
|
|
|
|
|
using namespace clang::clangd;
|
|
|
|
using namespace clang;
|
|
|
|
|
2017-08-01 23:51:38 +08:00
|
|
|
std::shared_ptr<CppFile> CppFileCollection::removeIfPresent(PathRef File) {
|
2017-05-16 17:38:59 +08:00
|
|
|
std::lock_guard<std::mutex> Lock(Mutex);
|
|
|
|
|
|
|
|
auto It = OpenedFiles.find(File);
|
|
|
|
if (It == OpenedFiles.end())
|
2017-08-01 23:51:38 +08:00
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
std::shared_ptr<CppFile> Result = It->second;
|
2017-05-16 17:38:59 +08:00
|
|
|
OpenedFiles.erase(It);
|
2017-08-01 23:51:38 +08:00
|
|
|
return Result;
|
2017-05-16 17:38:59 +08:00
|
|
|
}
|