[cfe-dev] clang-tidy FixItHint::CreateRemoval -- trailing semicolon stays

Tim Halloran via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 4 14:32:39 PST 2016


On Thu, Feb 4, 2016 at 5:18 PM, Piotr Dziwinski <piotrdz at gmail.com> wrote:

>
> As a workaround, you can try a different approach - store additional state
> in your check class and update it on each check() call.
> Then, once you have complete context information about the code you want
> to change, create a full diagnostic with all needed data.
>
> This is actually what I do in some of my checks, especially the localizing
> variables check that I'm still working on:
>
> https://github.com/piotrdz/clang-tools-extra/blob/master/clang-tidy/readability/LocalizingVariablesCheck.cpp
>

Yes this is a good idea, thanks. Sadly I need to do it at the very end
(your code seems to be able to trigger output (call diag()) based upon
function declaration scope.

I'm trying out using the destruction of the check class to report all the
issues. So, for example:

clang::SourceLocation foo;

UsingCheck::~UsingCheck() {
  std::cerr << "** destroy of UsingCheck instance\n";
  diag(foo, "bogus error for testing");
}

where I just stash a SourceLocation. The code above works (a simple
try-it-out test). I'm not sure if a destructor of a ClangTidyCheck class is
allowed to do this.  And I still need to stash SourceLocation and
SourceRange objects for this to work.

Best regards,
> Piotr Dziwinski
>

Thank you so much for the input, and the cool code pointer.
-- 
Tim Halloran
SureLogic, Inc.
5808 Forbes Avenue, Pittsburgh PA 15217-1602
(412) 722-3338
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160204/5ffaaaa3/attachment.html>


More information about the cfe-dev mailing list