[clang-tidy] Highlight "custom range" in diagnostic of check

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[clang-tidy] Highlight "custom range" in diagnostic of check

Kristof Beyls via cfe-dev
Hi List!

I'm currently working on a Tidy check which implements interface design rule from cppcoreguidelines ("avoid adjacent args of same type").

The problem with such a check is two-fold: the highlight of the diagnostic it should give isn't a singles AST node but a range.
But this->diag only accept a source location.

I'd wish to highlight a "custom" range (from beginning of one node's sourceloc through the last letter of another node, they appear sequentially in the source text).

I know fixit replace/delete hint works with ranges, but the diagnostic itself isn't about something that is trivially fixable with an automatically generated hint.

How would you go about doing this in a proper and user friendly way?
Putting two notes like "range begins here" and "range ends here" is ugly.

Regards, 
Whisperity.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [clang-tidy] Highlight "custom range" in diagnostic of check

Kristof Beyls via cfe-dev
On 21/10/2019 17:31, Whisperity via cfe-dev wrote:

> Hi List!
>
> I'm currently working on a Tidy check which implements interface design
> rule from cppcoreguidelines ("avoid adjacent args of same type").
>
> The problem with such a check is two-fold: the highlight of the
> diagnostic it should give isn't a singles AST node but a range.
> But this->diag only accept a source location.
>
> I'd wish to highlight a "custom" range (from beginning of one node's
> sourceloc through the last letter of another node, they appear
> sequentially in the source text).
>
> I know fixit replace/delete hint works with ranges, but the diagnostic
> itself isn't about something that is trivially fixable with an
> automatically generated hint.
>
> How would you go about doing this in a proper and user friendly way?
> Putting two notes like "range begins here" and "range ends here" is ugly.

Note also that the clang diagnostic reporting is designed for just one
line of source code. Your concurrent args might be on different lines.

I'd suggest two 'notes', one for each argument, or just one note
pointing out the latter argument.

Thanks,

Stephen.

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev