clang-tools 8.0.0

Context.cpp
Go to the documentation of this file.
1 //===--- Context.cpp ---------------------------------------------*- C++-*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "Context.h"
11 #include <cassert>
12
13 namespace clang {
14 namespace clangd {
15
16 Context Context::empty() { return Context(/*DataPtr=*/nullptr); }
17
18 Context::Context(std::shared_ptr<const Data> DataPtr)
19 : DataPtr(std::move(DataPtr)) {}
20
21 Context Context::clone() const { return Context(DataPtr); }
22
23 static Context &currentContext() {
24 static thread_local auto C = Context::empty();
25 return C;
26 }
27
28 const Context &Context::current() { return currentContext(); }
29
30 Context Context::swapCurrent(Context Replacement) {
31 std::swap(Replacement, currentContext());
32 return Replacement;
33 }
34
35 } // namespace clangd
36 } // namespace clang
Context.h
clang::clangd::currentContext
static Context & currentContext()
Definition: Context.cpp:23
clang::clangd::Context::swapCurrent
static Context swapCurrent(Context Replacement)
Definition: Context.cpp:30
clang::clangd::Context::clone
Context clone() const
Clone this context object.
Definition: Context.cpp:21
clang::clangd::Context::current
static const Context & current()
Returns the context for the current thread, creating it if needed.
Definition: Context.cpp:28
clang::clangd::Context
A context is an immutable container for per-request data that must be propagated through layers that ...
Definition: Context.h:70
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::clangd::Context::empty
static Context empty()
Returns an empty root context that contains no data.
Definition: Context.cpp:16
clang::clangd::Context::Context
Context()=default
Same as Context::empty(), please use Context::empty() instead.