mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Support pointer template params (#6810)
https://github.com/carbon-language/carbon-lang/issues/6717
This commit is contained in:
@@ -63,6 +63,7 @@
|
||||
#include "toolchain/sem_ir/ids.h"
|
||||
#include "toolchain/sem_ir/inst.h"
|
||||
#include "toolchain/sem_ir/name_scope.h"
|
||||
#include "toolchain/sem_ir/pattern.h"
|
||||
#include "toolchain/sem_ir/typed_insts.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
@@ -2312,4 +2313,25 @@ auto ImportClassDefinitionForClangDecl(Context& context,
|
||||
return true;
|
||||
}
|
||||
|
||||
auto GetAsClangVarDecl(Context& context, SemIR::InstId inst_id)
|
||||
-> clang::VarDecl* {
|
||||
if (const auto& var_storage =
|
||||
context.insts().TryGetAs<SemIR::VarStorage>(inst_id)) {
|
||||
auto var_name_id = SemIR::GetFirstBindingNameFromPatternId(
|
||||
context.sem_ir(), var_storage->pattern_id);
|
||||
if (auto cpp_global_var_id = context.sem_ir().cpp_global_vars().Lookup(
|
||||
{.entity_name_id = var_name_id});
|
||||
cpp_global_var_id.has_value()) {
|
||||
SemIR::ClangDeclId clang_decl_id = context.sem_ir()
|
||||
.cpp_global_vars()
|
||||
.Get(cpp_global_var_id)
|
||||
.clang_decl_id;
|
||||
return cast<clang::VarDecl>(
|
||||
context.clang_decls().Get(clang_decl_id).key.decl);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace Carbon::Check
|
||||
|
||||
Reference in New Issue
Block a user