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
@@ -62,10 +62,12 @@ import Cpp;
class Final {}
inline Cpp '''
// CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE+5]]:12: error: base 'Final' is marked 'final' [CppInteropParseError]
// CHECK:STDERR: 13 | struct A : Carbon::Final {};
// CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE+7]]:12: error: base 'Final' is marked 'final' [CppInteropParseError]
// CHECK:STDERR: 15 | struct A : Carbon::Final {};
// CHECK:STDERR: | ^
// CHECK:STDERR: note: 'Final' declared here [CppInteropParseNote]
// CHECK:STDERR: fail_derive_from_final.carbon:[[@LINE-6]]:13: note: 'Final' declared here [CppInteropParseNote]
// CHECK:STDERR: 5 | class Final {}
// CHECK:STDERR: | ^
// CHECK:STDERR:
struct A : Carbon::Final {};
''';
@@ -91,10 +93,12 @@ abstract class Abstract {
}
inline Cpp '''
// CHECK:STDERR: fail_abstract.carbon:[[@LINE+5]]:18: error: variable type 'Carbon::Abstract' is an abstract class [CppInteropParseError]
// CHECK:STDERR: 26 | Carbon::Abstract x;
// CHECK:STDERR: fail_abstract.carbon:[[@LINE+7]]:18: error: variable type 'Carbon::Abstract' is an abstract class [CppInteropParseError]
// CHECK:STDERR: 28 | Carbon::Abstract x;
// CHECK:STDERR: | ^
// CHECK:STDERR: note: unimplemented pure virtual method '~Abstract' in 'Abstract' [CppInteropParseNote]
// CHECK:STDERR: fail_abstract.carbon:[[@LINE-8]]:25: note: unimplemented pure virtual method '~Abstract' in 'Abstract' [CppInteropParseNote]
// CHECK:STDERR: 16 | abstract class Abstract {
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::Abstract x;
''';
@@ -66,9 +66,12 @@ import Cpp;
class A;
inline Cpp '''
// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE+4]]:11: error: variable has incomplete type 'Carbon::A' [CppInteropParseError]
// CHECK:STDERR: 16 | Carbon::A a;
// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE+7]]:11: error: variable has incomplete type 'Carbon::A' [CppInteropParseError]
// CHECK:STDERR: 19 | Carbon::A a;
// CHECK:STDERR: | ^
// CHECK:STDERR: fail_incomplete_concrete.carbon:[[@LINE-6]]:8: note: forward declaration of 'Carbon::A' [CppInteropParseNote]
// CHECK:STDERR: 9 | class A;
// CHECK:STDERR: | ^
// CHECK:STDERR:
Carbon::A a;
''';