Index: lib/CodeGen/CGExprCXX.cpp =================================================================== --- lib/CodeGen/CGExprCXX.cpp +++ lib/CodeGen/CGExprCXX.cpp @@ -107,6 +107,10 @@ ReturnValueSlot ReturnValue) { const Expr *callee = CE->getCallee()->IgnoreParens(); + // The debug information for the call instruction should point to the callee + // expression. + ApplyDebugLocation DL(*this, callee); + if (isa(callee)) return EmitCXXMemberPointerCallExpr(CE, ReturnValue); Index: test/CodeGenCXX/debug-info-member-call.cpp =================================================================== --- /dev/null +++ test/CodeGenCXX/debug-info-member-call.cpp @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -triple x86_64-unknown_unknown -emit-llvm -debug-info-kind=standalone -dwarf-column-info %s -o - | FileCheck %s +void ext(); + +struct Bar { + void bar() { ext(); } +}; + +struct Foo { + Bar *b; + + Bar *foo() { return b; } +}; + +void test(Foo *f) { + f->foo()->bar(); +} + +// CHECK-LABEL: @_Z4testP3Foo +// CHECK: call {{.*}} @_ZN3Foo3fooEv{{.*}}, !dbg ![[CALL1LOC:.*]] +// CHECK: call void @_ZN3Bar3barEv{{.*}}, !dbg ![[CALL2LOC:.*]] + +// CHECK: ![[CALL1LOC]] = !DILocation(line: [[LINE:[0-9]+]], column: 6, +// CHECK: ![[CALL2LOC]] = !DILocation(line: [[LINE]], column: 13, +