[llvm-branch-commits] [cfe-branch] r228078 - Merging r228053:

Hans Wennborg hans at hanshq.net
Tue Feb 3 16:00:37 PST 2015

Author: hans
Date: Tue Feb  3 18:00:36 2015
New Revision: 228078

URL: http://llvm.org/viewvc/llvm-project?rev=228078&view=rev
Merging r228053:
r228053 | dblaikie | 2015-02-03 14:37:17 -0800 (Tue, 03 Feb 2015) | 29 lines

DebugInfo: Ensure calls to functions with default arguments which themselves have default arguments, still have locations.

To handle default arguments in C++ in the debug info, we disable code
updating the debug location during the emission of default arguments.

This code was buggy in the case of default arguments which, themselves,
have default arguments - the inner default argument would re-enable
debug info when it was finished, but before the outer default argument
was finished.

This was already a bug, but got worse (because a crasher instead of just
a quality bug) with the recent improvements to debug info line quality
because... The ApplyDebugLocation scoped device would find the debug
info disabled and not save any debug location. But then in
~ApplyDebugLocation it would find the debug info had been enabled and
would then apply the no-location. Then the outer function call would be
emitted without any location. That's bad.

Arguably we could /also/ fix the ApplyDebugLocation to assert on this
situation (where debug info was disabled in the ctor and enabled in the
dtor, or the other way around) but this is at least the necessary fix

(also, I imagine this disabling behavior might need to be in-place for
CGExprComplex and CGExprAgg too, maybe... ?)

And I seem to recall seeing some weird default arg stepping behavior
recently which might be related to this too... I'll have to look into

    cfe/branches/release_36/   (props changed)

Propchange: cfe/branches/release_36/
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb  3 18:00:36 2015
@@ -1,4 +1,4 @@

Modified: cfe/branches/release_36/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/lib/CodeGen/CGExprScalar.cpp?rev=228078&r1=228077&r2=228078&view=diff
--- cfe/branches/release_36/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/branches/release_36/lib/CodeGen/CGExprScalar.cpp Tue Feb  3 18:00:36 2015
@@ -3393,11 +3393,12 @@ Value *CodeGenFunction::EmitScalarExpr(c
   assert(E && hasScalarEvaluationKind(E->getType()) &&
          "Invalid scalar expression to emit");
+  bool hasDebugInfo = getDebugInfo();
   if (isa<CXXDefaultArgExpr>(E))
   Value *V = ScalarExprEmitter(*this, IgnoreResultAssign)
-  if (isa<CXXDefaultArgExpr>(E))
+  if (isa<CXXDefaultArgExpr>(E) && hasDebugInfo)
   return V;

Modified: cfe/branches/release_36/test/CodeGenCXX/debug-info-line.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/test/CodeGenCXX/debug-info-line.cpp?rev=228078&r1=228077&r2=228078&view=diff
--- cfe/branches/release_36/test/CodeGenCXX/debug-info-line.cpp (original)
+++ cfe/branches/release_36/test/CodeGenCXX/debug-info-line.cpp Tue Feb  3 18:00:36 2015
@@ -184,6 +184,15 @@ f14_use::f14_use() = default;
 // CHECK-LABEL: define
+// CHECK-LABEL: define
+int f21_a(int = 0);
+void f21_b(int = f21_a());
+void f21() {
+// CHECK: call {{.*}}f21_b{{.*}}, !dbg [[DBG_F21:![0-9]*]]
+#line 2300
+  f21_b();
 // CHECK: [[DBG_F1]] = !MDLocation(line: 100,
 // CHECK: [[DBG_FOO_VALUE]] = !MDLocation(line: 200,
 // CHECK: [[DBG_FOO_REF]] = !MDLocation(line: 202,

More information about the llvm-branch-commits mailing list