]> granicus.if.org Git - clang/commitdiff
Force column info only for direct inlined functions. This should strike
authorAdrian Prantl <aprantl@apple.com>
Fri, 15 Mar 2013 17:09:05 +0000 (17:09 +0000)
committerAdrian Prantl <aprantl@apple.com>
Fri, 15 Mar 2013 17:09:05 +0000 (17:09 +0000)
the balance between expected behavior and compatibility with the gdb
testsuite.
(GDB gets confused if we break an expression into multiple debug
stmts so we enable this behavior only for inlined functions. For the
full experience people can still use -gcolumn-info.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177164 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp
test/CodeGenCXX/debug-info-same-line.cpp

index e551343119e478bd468ec6ffc3cfd617ee6eae53..ad69ebe05f7c9121ec16da057206cc2aa3f9b82d 100644 (file)
@@ -2857,9 +2857,11 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E,
                                      ReturnValueSlot ReturnValue) {
   if (CGDebugInfo *DI = getDebugInfo()) {
     SourceLocation Loc = E->getLocStart();
-    DI->EmitLocation(Builder, Loc,
-      /* Force column info to be generated so we can differentiate
-         multiple call sites on the same line in the debug info. */ true);
+    // Force column info to be generated so we can differentiate
+    // multiple call sites on the same line in the debug info.
+    const FunctionDecl* Callee = E->getDirectCallee();
+    bool ForceColumnInfo = Callee && Callee->isInlineSpecified();
+    DI->EmitLocation(Builder, Loc, ForceColumnInfo);
   }
 
   // Builtins never have block type.
index 59cd405ac5e2983fa9286f7402e8abfefc230697..17dc55ffcfb3b3111436a98463e101c10dd47457 100644 (file)
@@ -47,12 +47,15 @@ main(int argc, char const *argv[])
 {
 
     int array[3];
+    int n;
 
     array[0] = foo (1238, 78392);
     array[1] = foo (379265, 23674);
     array[2] = foo (872934, 234);
 
-    return 0;
+    n = strange_max(array[0], strange_max(array[1], array[2]));
+
+    return n & 0xf;
 }
 
 // CHECK: define {{.*}} @_Z3fooii
@@ -79,3 +82,17 @@ main(int argc, char const *argv[])
 // CHECK:     call void @llvm.dbg.declare(metadata !{i32* %{{.*}}}, metadata ![[B_MD]]), !dbg !{{.*}}
 // result
 // CHECK: call void @llvm.dbg.declare
+
+// CHECK: define {{.*}} @main
+// CHECK: call {{.*}} @_Z3fooii
+// CHECK: call {{.*}} @_Z3fooii
+// CHECK: call {{.*}} @_Z3fooii
+// CHECK: store
+// CHECK: getelementptr
+// We want to see the same !dbg node for non-inlined functions. 
+// Needed for GDB compatibility.
+// CHECK: load {{.*}} !dbg ![[DBG:.*]]
+// CHECK: load {{.*}} !dbg ![[DBG]]
+// CHECK: load {{.*}} !dbg ![[DBG]]
+// CHECK: call {{.*}} @_Z11strange_maxii(i32 %{{.*}}, i32 %{{.*}}), !dbg ![[DBG]]
+// CHECK: call {{.*}} @_Z11strange_maxii(i32 %{{.*}}, i32 %{{.*}}), !dbg ![[DBG]]