| //===--- Context.cpp -----------------------------------------*- C++-*-===// |
| // The LLVM Compiler Infrastructure |
| // This file is distributed under the University of Illinois Open Source |
| // License. See LICENSE.TXT for details. |
| //===---------------------------------------------------------------------===// |
| 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 ¤tContext() { |
| static thread_local auto C = Context::empty(); |
| const Context &Context::current() { return currentContext(); } |
| Context Context::swapCurrent(Context Replacement) { |
| std::swap(Replacement, currentContext()); |