context.cpp 808 B

1234567891011121314151617181920212223242526
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/check/cpp/context.h"
  5. #include "clang/AST/Mangle.h"
  6. namespace Carbon::Check {
  7. CppContext::CppContext(clang::CompilerInstance& instance,
  8. std::unique_ptr<clang::Parser> parser)
  9. : ast_context_(&instance.getASTContext()),
  10. sema_(&instance.getSema()),
  11. parser_(std::move(parser)) {}
  12. CppContext::~CppContext() = default;
  13. auto CppContext::clang_mangle_context() -> clang::MangleContext& {
  14. if (!clang_mangle_context_) {
  15. clang_mangle_context_.reset(ast_context().createMangleContext());
  16. }
  17. return *clang_mangle_context_;
  18. }
  19. } // namespace Carbon::Check