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

Tim Halloran via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 4 10:28:10 PST 2016


On Thu, Feb 4, 2016 at 11:37 AM, Piotr Dziwinski <piotrdz at gmail.com> wrote:

> Yes, you can add many fix it hints for a given diagnostic. For example:
>
>   auto Diagnostic = diag(Loc, "diagnostic");
>   Diagnostic.AddFixItHint(FixItHint::CreateInsertion(/*...*/));
>   Diagnostic.AddFixItHint(FixItHint::CreateRemoval(/*...*/));
>
> This can also be achieved through overloaded operator<< which is just a
> wrapper for the same function calls.
>

This works during the same call to "check"  However if I stash the pointer
to the "Diagnostic" variable (e.g., in a map) and lookup and use the
reference later I'm getting a core dump. I'm guessing that is because the
object created by "diag()" call is not intended to be stashed.

Is there a way to get a clang::DiagnosticBuilder object that can be safely
stashed?

What I am doing is first removing somthing like

using namespace sl;

from the code

then adding qualifiers for each use, e.g., "foo" becomes "sl::foo"

so the "add qualifier" part gets identified in later calls to "check"

>
> Best regards,
> Piotr Dziwinski
>
>
Thanks!
Tim
-- 
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/15833307/attachment.html>


More information about the cfe-dev mailing list