<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi Stuart,</p>
<p>I am not too active in the frontend, but in `lib/Parse/*` is the
code for parsing and it does emit FixitHints. You can grep around
with</p>
<p>`git grep "FixItHint::CreateInsertion"`</p>
<p>Documentation for FixIt:
<a class="moz-txt-link-freetext" href="https://clang.llvm.org/doxygen/classclang_1_1FixItHint.html">https://clang.llvm.org/doxygen/classclang_1_1FixItHint.html</a></p>
<p>Documentation for CFE Internals:
<a class="moz-txt-link-freetext" href="https://clang.llvm.org/docs/InternalsManual.html#fix-it-hints">https://clang.llvm.org/docs/InternalsManual.html#fix-it-hints</a><br>
</p>
<p>Someone else might give you more specific advice, but reading the
code and some doc might give you a good start :)<br>
</p>
<p>Best Jonas<br>
</p>
<br>
<div class="moz-cite-prefix">Am 05.10.2018 um 12:50 schrieb Stuart
Thomson:<br>
</div>
<blockquote type="cite"
cite="mid:F6EBF6E4EFB88541830D4E6CB6C78DCA5D4110@EDIEXCHANGE.local.tmvse.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;
mso-fareast-language:EN-GB;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;
mso-fareast-language:EN-US;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;
mso-fareast-language:EN-GB;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;
mso-fareast-language:EN-US;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:231505468;
mso-list-type:hybrid;
mso-list-template-ids:559848110 134807553 134807555 134807557 134807553 134807555 134807557 134807553 134807555 134807557;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:\F0B7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Symbol;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:\F0A7;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;
font-family:Wingdings;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext">Hi Jonas,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Thanks for
this.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<ul style="margin-top:0cm" type="disc">
<li class="MsoListParagraph"
style="color:windowtext;margin-left:0cm;mso-list:l0 level1
lfo1">
As far as I can tell clang does not emit a fix-it hint for
this error. There is no hint on the command line and running
clang-tidy with -fix-errors results in no change in the
source.<o:p></o:p></li>
<li class="MsoListParagraph"
style="color:windowtext;margin-left:0cm;mso-list:l0 level1
lfo1">
Dumping the AST shows the VarDecl in question but it is
marked “invalid”. Also when I try to write a matcher it
doesn’t seem to be able to find the initializer so I think
you are right that the node has been removed.<o:p></o:p></li>
</ul>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">I’m not sure
how exactly I would go about adding this to the frontend –
do you have any suggestions for how to begin?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext">Stuart<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="color:windowtext;mso-fareast-language:EN-GB"
lang="EN-US">From:</span></b><span
style="color:windowtext;mso-fareast-language:EN-GB"
lang="EN-US"> Jonas Toth
<a class="moz-txt-link-rfc2396E" href="mailto:development@jonas-toth.eu"><development@jonas-toth.eu></a>
<br>
<b>Sent:</b> 05 October 2018 11:05<br>
<b>To:</b> Stuart Thomson
<a class="moz-txt-link-rfc2396E" href="mailto:Stuart.Thomson@eu.medical.canon"><Stuart.Thomson@eu.medical.canon></a>;
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [cfe-dev] Writing a fix-it for
errors already found by clang<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Stuart, <span
style="mso-fareast-language:EN-GB"><o:p></o:p></span></p>
<div>
<p>does clang itself emit a fix-it hint? As it does for some
errors already, you could try to add this to the clang
frontend itself instead of a separate clang-tidy check.<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">clang-tidy
checks don't have information of other diagnostics from Sema
or other checks, each check is independent in that sense.
They use the AST as information.<br>
When there are errors in the original source-code, the
corresponding AST-Nodes could be removed to recover from
these errors. This makes it complicated to write<br>
a reliable clang-tidy check (if not impossible).<br>
<br>
Does 'clang-check -ast-dump file.cpp' contain the offending
nodes?<br>
<br>
Best Jonas<br>
(forgot to include cfe-dev)<o:p></o:p></p>
<div>
<p class="MsoNormal">Am 05.10.2018 um 11:56 schrieb Stuart
Thomson via cfe-dev:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">I want to write a clang-tidy check
which would fix something which clang currently considers
an error (namely initializing BSTR with const wchar_t *).
I am trying to write node matchers etc. but it seems like
it might be redundant given that clang already know when
this is happening. I wonder if there is some way to grab
the diagnostic messages and if the message matches a given
message (with a regex or something) clang could attempt to
fix the offending code?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Also, is this complicated by the fact
that this diagnostic is and error and not just a warning?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Stuart<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span
style="mso-fareast-language:EN-GB"><br>
<br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>cfe-dev mailing list<o:p></o:p></pre>
<pre><a href="mailto:cfe-dev@lists.llvm.org" moz-do-not-send="true">cfe-dev@lists.llvm.org</a><o:p></o:p></pre>
<pre><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><span style="mso-fareast-language:EN-GB"><o:p> </o:p></span></p>
</div>
</div>
</blockquote>
<br>
</body>
</html>