[cfe-commits] [PATCH] Suppress macro backtraces for notes

Richard Smith richard at metafoo.co.uk
Wed Dec 5 02:45:40 PST 2012


Based on a suggestion from Chandler, the attached patch suppresses
macro backtraces for notes.

First, the "best" macro in the expansion chain is chosen (the lowest
ancestor of all the source locations provided for the diagnostic in
its caret, ranges and fixits). Then we walk up until we hit a line
which we also displayed in the macro backtrace for the primary
diagnostic. If we don't hit one, we just display the (distal)
expansion location for the note.

For instance:

#define FOO(x) x BAR;
#define BAR baz
#define QUUX FOO(int) FOO(double)
QUUX

Previously:

<stdin>:4:1: error: redefinition of 'baz' with a different type: 'double' vs
      'int'
QUUX
^
<stdin>:3:23: note: expanded from macro 'QUUX'
#define QUUX FOO(int) FOO(double)
                      ^
<stdin>:1:18: note: expanded from macro 'FOO'
#define FOO(x) x BAR;
                 ^
<stdin>:2:13: note: expanded from macro 'BAR'
#define BAR baz
            ^
<stdin>:4:1: note: previous definition is here
QUUX
^
<stdin>:3:14: note: expanded from macro 'QUUX'
#define QUUX FOO(int) FOO(double)
             ^
<stdin>:1:18: note: expanded from macro 'FOO'
#define FOO(x) x BAR;
                 ^
<stdin>:2:13: note: expanded from macro 'BAR'
#define BAR baz
            ^

Now:

<stdin>:4:1: error: redefinition of 'baz' with a different type: 'double' vs
      'int'
QUUX
^
<stdin>:3:23: note: expanded from macro 'QUUX'
#define QUUX FOO(int) FOO(double)
                      ^
<stdin>:1:18: note: expanded from macro 'FOO'
#define FOO(x) x BAR;
                 ^
<stdin>:2:13: note: expanded from macro 'BAR'
#define BAR baz
            ^
<stdin>:3:14: note: previous definition is here
#define QUUX FOO(int) FOO(double)
             ^

Thoughts?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: no-note-backtraces.diff
Type: application/octet-stream
Size: 10651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20121205/6f87084f/attachment.obj>


More information about the cfe-commits mailing list