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

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Wed Oct 23 14:36:33 PDT 2019


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.




More information about the cfe-dev mailing list