llvm-project/clang/test/CodeGenCXX/debug-info-explicit-this.cpp
Michael Buch 2db0c00e60
[clang][CGDebugInfo] Don't generate an implicit 'this' parameter if one was specified explicitly (#100767)
Currently we would unconditionally add an implicit `this` parameter when
creating an instance method type. However, when we have an explicit
'this', we shouldn't generate one. This patch only passes a valid
`ThisPtr` type to `getOrCreateInstanceMethodType` if one wasn't
explicitly specified. There's no way to get a pointer to a member
function with an explicit `this` parameter (those are treated as regular
function pointers instead). So there's no need to account for that case
in `CGDebugInfo::CreateType`.

Fixes https://github.com/llvm/llvm-project/issues/99744
2024-07-29 08:47:02 +01:00

17 lines
696 B
C++

// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -std=c++2b %s -o - | FileCheck %s
struct Foo {
void Bar(this Foo&& self) {}
};
void fn() {
Foo{}.Bar();
}
// CHECK: distinct !DISubprogram(name: "Bar", {{.*}}, type: ![[BAR_TYPE:[0-9]+]], {{.*}}, declaration: ![[BAR_DECL:[0-9]+]], {{.*}}
// CHECK: ![[FOO:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo"
// CHECK: ![[BAR_DECL]] = !DISubprogram(name: "Bar", {{.*}}, type: ![[BAR_TYPE]], {{.*}},
// CHECK: ![[BAR_TYPE]] = !DISubroutineType(types: ![[PARAMS:[0-9]+]])
// CHECK: ![[PARAMS]] = !{null, ![[SELF:[0-9]+]]}
// CHECK: ![[SELF]] = !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[FOO]]