<p dir="ltr">Yeah. I can't see a difference here being useful, and more likely harmful.</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, Aug 25, 2015, 8:48 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Aug 25, 2015 at 8:44 AM, Bataev, Alexey <span dir="ltr"><<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Debug info points to the real place where it is captured, while diagnostics points to the first use of implicitly captured variable.</blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>Right, but I'm trying to understand the justification for why that's the right thing to do. Why the debug info user would want a different experience than the compiler diagnostic consumer would want.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br><br>- David<br> </div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
<br>
Best regards,<br>
Alexey Bataev<br>
=============<br>
Software Engineer<br>
Intel Compiler Team<br>
<br>
</span><a href="tel:25.08.2015%2018" value="+12508201518" target="_blank">25.08.2015 18</a>:22, David Blaikie пишет:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>
<br>
<br>
On Tue, Aug 25, 2015 at 8:18 AM, Bataev, Alexey <<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a> <mailto:<a href="mailto:a.bataev@hotmail.com" target="_blank">a.bataev@hotmail.com</a>>> wrote:<br>
<br>
    I though about this. I think it will be more convenient for user<br>
    to see the diagnostic on the first use of the variable rather than<br>
    on '=' or '&' symbol.<br>
<br>
<br>
Why the difference between the diagnostic & the debug info, then?<br>
<br>
<br>
    Best regards,<br>
    Alexey Bataev<br>
    =============<br>
    Software Engineer<br>
    Intel Compiler Team<br>
<br></span>
    <a href="tel:25.08.2015%2018" value="+12508201518" target="_blank">25.08.2015 18</a> <tel:25.08.2015%2018>:07, David Blaikie пишет:<span><br>
<br>
<br>
<br>
        On Tue, Aug 18, 2015 at 9:05 PM, Alexey Bataev via cfe-commits<br>
        <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
        <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br></span>
        <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><div><div><br>
        <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>>> wrote:<br>
<br>
            ABataev created this revision.<br>
            ABataev added reviewers: echristo, rjmccall, rsmith.<br>
            ABataev added a subscriber: cfe-commits.<br>
<br>
            When variables are implicitly captured in lambdas, debug info<br>
            generated for captured variables points to location where<br>
        they are<br>
            used first.  This patch makes debug info to point to capture<br>
            default location.<br>
<br>
<br>
        Not sure if this is the right tradeoff, or if it is, perhaps<br>
        we should reconsider how our diagnostics work too?<br>
<br>
        Currently if you, say, capture a variable by value and that<br>
        variable doesn't have an accessible copy ctor, the diagnostic<br>
        points to the first use. Should we change that too?<br>
<br>
<br>
        <a href="http://reviews.llvm.org/D12134" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12134</a><br>
<br>
            Files:<br>
              lib/Sema/SemaLambda.cpp<br>
              test/CodeGenCXX/debug-lambda-expressions.cpp<br>
<br>
            Index: lib/Sema/SemaLambda.cpp<br>
        ===================================================================<br>
            --- lib/Sema/SemaLambda.cpp<br>
            +++ lib/Sema/SemaLambda.cpp<br>
            @@ -1377,10 +1377,10 @@<br>
             }<br>
<br>
             static ExprResult performLambdaVarCaptureInitialization(<br>
            -    Sema &S, LambdaScopeInfo::Capture &Capture,<br>
            -    FieldDecl *Field,<br>
            +    Sema &S, LambdaScopeInfo::Capture &Capture, FieldDecl<br>
        *Field,<br>
                 SmallVectorImpl<VarDecl *> &ArrayIndexVars,<br>
            -    SmallVectorImpl<unsigned> &ArrayIndexStarts) {<br>
            +    SmallVectorImpl<unsigned> &ArrayIndexStarts, bool<br>
            ImplicitCapture,<br>
            +    SourceLocation CaptureDefaultLoc) {<br>
               assert(Capture.isVariableCapture() && "not a variable<br>
        capture");<br>
<br>
               auto *Var = Capture.getVariable();<br>
            @@ -1399,7 +1399,10 @@<br>
               //   An entity captured by a lambda-expression is<br>
        odr-used (3.2) in<br>
               //   the scope containing the lambda-expression.<br>
               ExprResult RefResult = S.BuildDeclarationNameExpr(<br>
            -      CXXScopeSpec(), DeclarationNameInfo(Var->getDeclName(),<br>
            Loc), Var);<br>
            +      CXXScopeSpec(),<br>
            + DeclarationNameInfo(Var->getDeclName(),<br>
            +                          ImplicitCapture ?<br>
        CaptureDefaultLoc : Loc),<br>
            +      Var);<br>
               if (RefResult.isInvalid())<br>
                 return ExprError();<br>
               Expr *Ref = RefResult.get();<br>
            @@ -1561,7 +1564,8 @@<br>
                   Expr *Init = From.getInitExpr();<br>
                   if (!Init) {<br>
                     auto InitResult =<br>
        performLambdaVarCaptureInitialization(<br>
            -            *this, From, *CurField, ArrayIndexVars,<br>
            ArrayIndexStarts);<br>
            +            *this, From, *CurField, ArrayIndexVars,<br>
        ArrayIndexStarts,<br>
            +            CaptureDefault != LCD_None, CaptureDefaultLoc);<br>
                     if (InitResult.isInvalid())<br>
                       return ExprError();<br>
                     Init = InitResult.get();<br>
            Index: test/CodeGenCXX/debug-lambda-expressions.cpp<br>
        ===================================================================<br>
            --- test/CodeGenCXX/debug-lambda-expressions.cpp<br>
            +++ test/CodeGenCXX/debug-lambda-expressions.cpp<br>
            @@ -14,6 +14,19 @@<br>
             struct D { D(); D(const D&); int x; };<br>
             int d(int x) { D y[10]; return [x,y] { return y[x].x; }(); }<br>
<br>
            +// CHECK-LABEL: foo<br>
            +int foo(int x) {<br>
            +// CHECK: [[X:%.+]] = alloca i32,<br>
            +// CHECK: call void @llvm.dbg.declare(<br>
            +// CHECK: [[X_REF:%.+]] = getelementptr inbounds %{{.+}},<br>
            %{{.+}}* %{{.+}}, i32 0, i32 0, !dbg ![[DBG_FOO:[0-9]+]]<br>
            +// CHECK: [[X_VAL:%.+]] = load i32, i32* [[X]], align 4, !dbg<br>
            ![[DBG_FOO]]<br>
            +// CHECK: store i32 [[X_VAL]], i32* [[X_REF]], align 4, !dbg<br>
            ![[DBG_FOO]]<br>
            +// CHECK: call i32 @{{.+}}, !dbg ![[DBG_FOO]]<br>
            +  return [=] {<br>
            +    return x;<br>
            +  }();<br>
            +}<br>
            +<br>
             // Randomness for file. -- 6<br>
             // CHECK: [[FILE:.*]] = !DIFile(filename:<br>
            "{{.*}}debug-lambda-expressions.cpp",<br>
<br>
            @@ -100,3 +113,5 @@<br>
             // CHECK-SAME:                          line: [[VAR_LINE]],<br>
             // CHECK-SAME: elements:<br>
            ![[VAR_ARGS:[0-9]+]]<br>
             // CHECK: ![[VAR_ARGS]] = !{!{{[0-9]+}}}<br>
            +<br>
            +// CHECK: [[DBG_FOO:![0-9]+]] = !DILocation(line: 25,<br>
<br>
<br>
<br>
            _______________________________________________<br>
            cfe-commits mailing list<br>
        <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a> <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>><br></div></div>
        <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
        <mailto:<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>>><br>
        <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div></div></div></blockquote></div>