blob: 1a9ef24ff56a1096ea1d949f039001f9a30e77d9 [file] [log] [blame]
//===--- Context.cpp -----------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===---------------------------------------------------------------------===//
#include "Context.h"
#include <cassert>
namespace clang {
namespace clangd {
Context Context::empty() { return Context(/*DataPtr=*/nullptr); }
Context::Context(std::shared_ptr<const Data> DataPtr)
: DataPtr(std::move(DataPtr)) {}
Context Context::clone() const { return Context(DataPtr); }
static Context &currentContext() {
static thread_local auto C = Context::empty();
return C;
}
const Context &Context::current() { return currentContext(); }
Context Context::swapCurrent(Context Replacement) {
std::swap(Replacement, currentContext());
return Replacement;
}
} // namespace clangd
} // namespace clang