On Wed, Dec 5, 2012 at 8:57 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Wed, Dec 5, 2012 at 2:45 AM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br>
> Based on a suggestion from Chandler, the attached patch suppresses<br>
> macro backtraces for notes.<br>
><br>
> First, the "best" macro in the expansion chain is chosen (the lowest<br>
> ancestor of all the source locations provided for the diagnostic in<br>
> its caret, ranges and fixits). Then we walk up until we hit a line<br>
> which we also displayed in the macro backtrace for the primary<br>
> diagnostic. If we don't hit one, we just display the (distal)<br>
> expansion location for the note.<br>
><br>
> For instance:<br>
><br>
> #define FOO(x) x BAR;<br>
> #define BAR baz<br>
> #define QUUX FOO(int) FOO(double)<br>
> QUUX<br>
><br>
> Previously:<br>
><br>
> <stdin>:4:1: error: redefinition of 'baz' with a different type: 'double' vs<br>
>       'int'<br>
> QUUX<br>
> ^<br>
> <stdin>:3:23: note: expanded from macro 'QUUX'<br>
> #define QUUX FOO(int) FOO(double)<br>
>                       ^<br>
> <stdin>:1:18: note: expanded from macro 'FOO'<br>
> #define FOO(x) x BAR;<br>
>                  ^<br>
> <stdin>:2:13: note: expanded from macro 'BAR'<br>
> #define BAR baz<br>
>             ^<br>
> <stdin>:4:1: note: previous definition is here<br>
> QUUX<br>
> ^<br>
> <stdin>:3:14: note: expanded from macro 'QUUX'<br>
> #define QUUX FOO(int) FOO(double)<br>
>              ^<br>
> <stdin>:1:18: note: expanded from macro 'FOO'<br>
> #define FOO(x) x BAR;<br>
>                  ^<br>
> <stdin>:2:13: note: expanded from macro 'BAR'<br>
> #define BAR baz<br>
>             ^<br>
><br>
> Now:<br>
><br>
> <stdin>:4:1: error: redefinition of 'baz' with a different type: 'double' vs<br>
>       'int'<br>
> QUUX<br>
> ^<br>
> <stdin>:3:23: note: expanded from macro 'QUUX'<br>
> #define QUUX FOO(int) FOO(double)<br>
>                       ^<br>
> <stdin>:1:18: note: expanded from macro 'FOO'<br>
> #define FOO(x) x BAR;<br>
>                  ^<br>
> <stdin>:2:13: note: expanded from macro 'BAR'<br>
> #define BAR baz<br>
>             ^<br>
> <stdin>:3:14: note: previous definition is here<br>
> #define QUUX FOO(int) FOO(double)<br>
>              ^<br>
><br>
> Thoughts?<br>
<br>
</div></div>Should we note trace down through the FOO(int) macro instantiation? Or<br>
is the logic here that we've already traced through some FOO macro<br>
instantiation so we won't do another? Or more specific than that, only<br>
if the trace is the same?<br></blockquote><div><br></div><div>It's more specific: only if it's the *same* macro expansion as one we've already seen. (The idea is that you should be able to look at the line, see it's the same as one you just saw a few lines above, and assume that you got there in the same way.)</div>
</div>