Add 'remark' diagnostic type in clang

Arthur O'Dwyer arthur.j.odwyer at gmail.com
Thu Feb 27 19:24:24 PST 2014


On Thu, Feb 27, 2014 at 6:57 PM, Richard Smith <richard at metafoo.co.uk>wrote:

>
>>> This patch provides the initial implementation of 'remarks'. It includes
>>> the actual definiton of the remark nodes, their printing as well as basic
>>> parameter handling. We are reusing the existing diagnostic parameters which
>>> means a remark
>>> can be enabled with normal '-Wdiagnostic-name' flags and can be upgraded
>>> to an error using '-Werror=diagnostic-name'.
>>>
>>
>> For the record, I strongly recommend that the syntax to enable a remark
>> should be "-Wremark=diagnostic-name", and that "-Wdiagnostic-name" should
>> (continue to) mean "upgrade this diagnostic to a warning".
>> However, I have no objection to the current semantics for an initial
>> checkin, as long as nobody uses it as an excuse to keep those semantics
>> forever.
>>
>
> I'm not following something here. If it makes sense for a diagnostic to be
> upgraded to an error, why would it be a remark rather than a warning? Put
> another way, if a remark describes something that might indicate a problem,
> then what is the difference between a remark and a warning, and why do we
> need a new kind of thing in the first place?
>

Errors stop the build; warnings and remarks don't.
Warnings and errors are printed to the user by default; remarks require a
little extra effort on the user's part.

The OP's use-case, IIUC, is that he wants to be notified whenever the
compiler fails to vectorize a loop that has been annotated for
vectorization; but he doesn't want the diagnostic to be as severe as a
warning. (Although, now that I think about it, I'm not sure why he couldn't
just add a new warning -Wvectorization-failed that was disabled by default;
this use-case is pretty much orthogonal to remarks.)

EDG's use-case was that a "warning" was something that would likely be
useful to everyone; a "remark" was something that would likely be of
interest to everyone but too spammy to turn on by default (for example,
"switch case fallthrough" or "method declared without the virtual keyword
is nevertheless virtual"); and "silent" was for things that weren't of
general interest (for example "C-style cast in C++" or "recursive functions
are disallowed by MISRA").


I would have thought that the difference is that a remark indicates
> something that *isn't* a problem, and is just informational. That being the
> case, it doesn't make sense to me to upgrade remarks to warnings or to
> errors.
>

A user wants to stop the build when a particular diagnostic is issued. The
way you do that in most compilers (Clang included) is to pass
"-Werror=the-diagnostic". Whether the diagnostic started out as a remark or
a warning is irrelevant to the user.


> It would seem bizarre to me if -Werror converts remarks to errors (and
> indeed, in this patch, it does not).
>

Agreed. Unadorned "-Werror" should remain a synonym for "-Werror=warnings".


> I think we should also reject -Werror=some-remark.
>

Disagreed; how else would a user promote some-remark to the build-stopping
"error" severity level?  (Assuming that we keep the concept of "remarks" at
all, that is.)

–Arthur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140227/ef84d79d/attachment.html>


More information about the cfe-commits mailing list