mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Make multiple imports of the same header only parse it once per C++ domain. Reuse of the same header in `--share-cpp-ast` mode now reuses the representation. Importing a Carbon file with C++ dependencies now makes those transitive C++ dependencies in the same C++ domain visible too. Assisted-by: Gemini via Antigravity
59 lines
1.7 KiB
C++
59 lines
1.7 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include "toolchain/sem_ir/cpp_file.h"
|
|
|
|
#include "clang/AST/Mangle.h"
|
|
#include "clang/Basic/Diagnostic.h"
|
|
#include "clang/Frontend/CompilerInstance.h"
|
|
#include "common/check.h"
|
|
|
|
namespace Carbon::SemIR {
|
|
|
|
CppFile::CppFile(std::shared_ptr<clang::CompilerInstance> clang,
|
|
std::unique_ptr<clang::MangleContext> mangle_context,
|
|
llvm::LLVMContext* llvm_context,
|
|
clang::CodeGenerator* code_generator, CppDomain* cpp_domain)
|
|
: clang_(std::move(clang)),
|
|
mangle_context_(std::move(mangle_context)),
|
|
llvm_context_(llvm_context),
|
|
code_generator_(code_generator),
|
|
cpp_domain_(cpp_domain) {}
|
|
|
|
CppFile::~CppFile() = default;
|
|
|
|
auto CppFile::diagnostic_options() const -> const clang::DiagnosticOptions& {
|
|
return clang_->getDiagnostics().getDiagnosticOptions();
|
|
}
|
|
|
|
auto CppFile::lang_options() const -> const clang::LangOptions& {
|
|
return clang_->getLangOpts();
|
|
}
|
|
|
|
auto CppFile::source_manager() -> clang::SourceManager& {
|
|
return clang_->getSourceManager();
|
|
}
|
|
|
|
auto CppFile::source_manager() const -> const clang::SourceManager& {
|
|
return clang_->getSourceManager();
|
|
}
|
|
|
|
auto CppFile::diagnostics() const -> clang::DiagnosticsEngine& {
|
|
return clang_->getDiagnostics();
|
|
}
|
|
|
|
auto CppFile::ast_context() -> clang::ASTContext& {
|
|
return clang_->getASTContext();
|
|
}
|
|
|
|
auto CppFile::ast_context() const -> const clang::ASTContext& {
|
|
return clang_->getASTContext();
|
|
}
|
|
|
|
auto CppFile::mangle_context() const -> clang::MangleContext& {
|
|
return *mangle_context_;
|
|
}
|
|
|
|
} // namespace Carbon::SemIR
|