[PATCH] D19708: [CGDebugInfo] Generate debug info for member calls in the context of the callee expression

Hal Finkel via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 29 09:19:47 PDT 2016


hfinkel updated this revision to Diff 55610.
hfinkel added a comment.

Use David's suggested approach: 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 seems to cleanly fix the debug-info problem.


http://reviews.llvm.org/D19708

Files:
  include/clang/AST/ExprCXX.h
  test/CodeGenCXX/debug-info-member-call.cpp

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,
+
Index: include/clang/AST/ExprCXX.h
===================================================================
--- include/clang/AST/ExprCXX.h
+++ include/clang/AST/ExprCXX.h
@@ -145,6 +145,14 @@
   /// 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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19708.55610.patch
Type: text/x-patch
Size: 1378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160429/b3de7770/attachment-0001.bin>


More information about the cfe-commits mailing list