mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 11:11:05 +01:00
Encapsulate clang::ASTUnit in SemIR::CppFile. (#6459)
This intends to avoid proliferation of dependencies on the exact API of `clang::ASTUnit`, and would enable us to more easily switch to a different approach that gives us more control over the construction of the Clang AST. Also remove some unnecessary tracking of the `CppFile` and instead always retrieve it from the `SemIR::File`. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
78025fed70
commit
d208e950c7
@@ -0,0 +1,19 @@
|
||||
// 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"
|
||||
|
||||
namespace Carbon::SemIR {
|
||||
|
||||
auto CppFile::VisitLocalTopLevelDecls(
|
||||
llvm::function_ref<void(const clang::Decl*)> visitor) const -> void {
|
||||
ast_unit_->visitLocalTopLevelDecls(
|
||||
&visitor, [](void* erased_visitor_ptr, const clang::Decl* decl) {
|
||||
auto* visitor_ptr = static_cast<decltype(visitor)*>(erased_visitor_ptr);
|
||||
(*visitor_ptr)(decl);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace Carbon::SemIR
|
||||
Reference in New Issue
Block a user