Author: hfinkel Date: Wed May 25 17:08:27 2016 New Revision: 270775 URL: http://llvm.org/viewvc/llvm-project?rev=270775&view=rev Log: [CGDebugInfo] Modify the preferred expression location for member calls.
If the callee has a valid location (not all do), then use that. Otherwise, fall back to the starting location. This makes sure that the debug info for calls points to the call (not the start of the expression providing the object on which the member function is being called). For example, given this: f->foo()->bar(); we don't want both calls to point to the 'f', but rather to the 'foo()' and the 'bar()'. Fixes PR27567. Differential Revision: http://reviews.llvm.org/D19708 Added: cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp Modified: cfe/trunk/include/clang/AST/ExprCXX.h Modified: cfe/trunk/include/clang/AST/ExprCXX.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=270775&r1=270774&r2=270775&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExprCXX.h (original) +++ cfe/trunk/include/clang/AST/ExprCXX.h Wed May 25 17:08:27 2016 @@ -143,6 +143,14 @@ public: /// FIXME: Returns 0 for member pointer call exprs. CXXRecordDecl *getRecordDecl() const; + SourceLocation getExprLoc() const LLVM_READONLY { + SourceLocation CLoc = getCallee()->getExprLoc(); + if (CLoc.isValid()) + return CLoc; + + return getLocStart(); + } + static bool classof(const Stmt *T) { return T->getStmtClass() == CXXMemberCallExprClass; } Added: cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp?rev=270775&view=auto ============================================================================== --- cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp (added) +++ cfe/trunk/test/CodeGenCXX/debug-info-member-call.cpp Wed May 25 17:08:27 2016 @@ -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, + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits