Add location to clang classes created via reverse interop (#7533)

The specific location's not ideal (rather than the open curly, or
semicolon for a declaration - the two locations should be the `class`
and then the class name), but the same as we do for functions for now &
enough to get by.

This specifically also fixes a crash I found due to dtors being
generated without a location (because implicitly created functions would
use the class's location), creating a function call without a debug
location, which fails the LLVM IR verifier.
This commit is contained in:
David Blaikie
2026-07-18 00:13:05 +00:00
committed by GitHub
parent 5c544f7c2f
commit 99cda60df7
4 changed files with 24 additions and 13 deletions
+4 -3
View File
@@ -156,10 +156,11 @@ auto ExportClassToCpp(Context& context, SemIR::LocId loc_id,
auto* decl_context =
ExportNameScopeToCpp(context, loc_id, class_info.parent_scope_id);
// TODO: Provide a source location.
auto clang_loc =
GetCppLocation(context, SemIR::LocId(class_info.first_decl_id()));
auto* record_decl = clang::CXXRecordDecl::Create(
context.ast_context(), clang::TagTypeKind::Class, decl_context,
clang::SourceLocation(), clang::SourceLocation(), identifier_info);
context.ast_context(), clang::TagTypeKind::Class, decl_context, clang_loc,
clang_loc, identifier_info);
// If this is a member class, set its access.
if (isa<clang::CXXRecordDecl>(decl_context)) {
// TODO: Map Carbon access to C++ access.