We currently generate debug info for member calls in the context of the call expression. For member calls, this has an odd effect, which becomes especially obvious when generating source locations for optimizer-feedback remarks regarding inlining.
Given this:
$ cat -n /tmp/i.cpp 1 void ext(); 2 3 struct Bar { 4 void bar() { ext(); } 5 }; 6 7 struct Foo { 8 Bar *b; 9 10 Bar *foo() { return b; } 11 }; 12 13 void test(Foo *f) { 14 f->foo()->bar(); 15 } $ clang -g /tmp/i.cpp -S -emit-llvm -o - define void @_Z4testP3Foo(%struct.Foo* %f) #0 !dbg !6 { ... %call = call %struct.Bar* @_ZN3Foo3fooEv(%struct.Foo* %0), !dbg !27 call void @_ZN3Bar3barEv(%struct.Bar* %call), !dbg !28 ... !27 = !DILocation(line: 14, column: 3, scope: !6) !28 = !DILocation(line: 14, column: 3, scope: !29)
but we want instead for the calls to point to the callee expressions (foo() and bar() in this case). With this change, that's what happens.
Fixes PR27567.