[cfe-commits] r142127 - in /cfe/trunk: lib/Frontend/TextDiagnostic.cpp test/Misc/caret-diags-macros.c test/Misc/include-stack-for-note-flag.cpp test/Misc/macro-backtrace.c

Ahmed Charles ahmedcharles at gmail.com
Sun Oct 16 11:04:49 PDT 2011


On Sun, Oct 16, 2011 at 2:30 AM, Chandler Carruth <chandlerc at gmail.com> wrote:
> Author: chandlerc
> Date: Sun Oct 16 04:30:08 2011
> New Revision: 142127
>
> URL: http://llvm.org/viewvc/llvm-project?rev=142127&view=rev
> Log:
> Now that macro expansion notes are real notes and go through the same
> formatting as any other diagnostic, they will be properly line wrapped and
> otherwise pretty printed. Let's take advantage of that and the new factoring to
> add some helpful information to them (much like template backtrace notes and
> other notes): the name of the macro whose expansion is being noted. This makes
> a world of difference if caret diagnostics are disabled, making the expansion
> notes actually useful in this case. It also helps ensure that in edge cases the
> information the user needs is present. Consider:
>
> % nl -ba t5.cc
>     1  #define M(x, y, z) \
>     2    y
>     3
>     4  M(
>     5    1,
>     6    2,
>     7    3);
>
> We now produce:
> % ./bin/clang -fsyntax-only t5.cc
> t5.cc:6:3: error: expected unqualified-id
>  2,
>  ^
> t5.cc:2:3: note: expanded from macro: M
>  y
>  ^
> 1 error generated.
>
> Without the added information in the note, the name of the macro being expanded
> would never be shown.
>
> This also deletes a FIXME to use the diagnostic formatting. It's not yet clear
> to me that we *can* do this reasonably, and the production of this message was
> my primary goal here anyways.
>
> I'd love any comments or suggestions on improving these notes, their wording,
> etc. Currently, I need to make them provide more helpful information in the
> presence of a token-pasting buffer, and I'm pondering adding something along
> the lines of "expanded from argument N of macro: ...".
>

I think adding the argument name/index would be helpful... and well,
it doesn't hurt to have it.




More information about the cfe-commits mailing list