<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
span.E-MailFormatvorlage19
{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:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1578704206;
mso-list-template-ids:-875234650;}
@list l0:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l0:level2
{mso-level-number-format:bullet;
mso-level-text:o;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:"Courier New";
mso-bidi-font-family:"Times New Roman";}
@list l0:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level5
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level8
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l0:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Wingdings;}
@list l1
{mso-list-id:1721318428;
mso-list-template-ids:1792323232;}
@list l1:level1
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:36.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level2
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:72.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level3
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:108.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level4
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:144.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level5
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:180.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level6
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:216.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level7
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:252.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level8
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:288.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
@list l1:level9
{mso-level-number-format:bullet;
mso-level-text:;
mso-level-tab-stop:324.0pt;
mso-level-number-position:left;
text-indent:-18.0pt;
mso-ansi-font-size:10.0pt;
font-family:Symbol;}
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]--></head><body lang=DE link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>I’m not sure of the exact list.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>At least DeclStmt includes the semicolon:<o:p></o:p></span></p><p class=MsoNormal><a href="https://github.com/llvm/llvm-project/blob/master/clang/lib/Parse/ParseDecl.cpp#L1801"><span lang=EN-US>https://github.com/llvm/llvm-project/blob/master/clang/lib/Parse/ParseDecl.cpp#L1801</span></a><span lang=EN-US><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>But this does not matter that much. If tracking those Semicolons is too much, then it probably does<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>not matter much whether all Stmt behave the same or not as long as there is a way to get a location<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>with semicolon for those that need it.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>I would try to add a comment to Stmt.getEndLoc to describe this as it’s at least surprising otherwise.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'>Alexander<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='mso-fareast-language:EN-US'><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>Von:</b> rjmccall@apple.com <rjmccall@apple.com> <br><b>Gesendet:</b> Dienstag, 17. <span lang=EN-US>März 2020 06:11<br><b>An:</b> alex@lanin.de<br><b>Cc:</b> Clang Dev <cfe-dev@lists.llvm.org><br><b>Betreff:</b> Re: [cfe-dev] Extend Stmt with proper end location?<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><div><div><p><span lang=EN-US style='font-family:"Arial",sans-serif'>On 13 Mar 2020, at 5:08, via cfe-dev wrote:<o:p></o:p></span></p></div><div><blockquote style='border:none;border-left:solid #777777 1.5pt;padding:0cm 0cm 0cm 4.0pt;margin-left:0cm;margin-top:5.0pt;margin-right:0cm;margin-bottom:3.75pt'><p><span lang=EN-US style='font-family:"Arial",sans-serif;color:#777777'>currently Stmt getEndLoc returns slightly different results depending on Stmt type.<br>Specifically DoWhile, GotoStmt, ContinueStmt, BreakStmt, ReturnStmt, AsmStmt and SEHLeaveStmt do not track the location of the mandatory semicolon at the end.<br>(Expr is out of scope of this mail thread)<o:p></o:p></span></p></blockquote></div><div><p><span lang=EN-US style='font-family:"Arial",sans-serif'>To be precise, the only statement that <em><span style='font-family:"Arial",sans-serif'>does</span></em> track the location<br>of the semicolon is </span><code><span lang=EN-US style='font-size:10.0pt;color:black;background:#F7F7F7'>NullStmt</span></code><span lang=EN-US style='font-family:"Arial",sans-serif'>, and that’s only because it would<br>otherwise have no associated source locations and so could not<br>meaningfully implement </span><code><span lang=EN-US style='font-size:10.0pt;color:black;background:#F7F7F7'>getSourceRange()</span></code><span lang=EN-US style='font-family:"Arial",sans-serif'>.<o:p></o:p></span></p><p><span lang=EN-US style='font-family:"Arial",sans-serif'>The Clang AST serves several different masters. It’s understood<br>that some of the information we track for the use of source tools<br>isn’t very useful for compilation, and maybe the reverse as well.<br>We do accept that this adds overhead to compilation. But we’ve<br>generally drawn the line at storing delimiters because:<o:p></o:p></span></p><ul type=disc><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3'><span lang=EN-US style='font-family:"Arial",sans-serif'>vanishingly few clients of the AST need exact delimiter locations,<o:p></o:p></span></li><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3'><span lang=EN-US style='font-family:"Arial",sans-serif'>the clients that do care need them for vanishingly few AST nodes,<o:p></o:p></span></li><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3'><span lang=EN-US style='font-family:"Arial",sans-serif'>there are an awful lot of delimiters in a typical program, and storing them all would eat a lot of memory, and<o:p></o:p></span></li><li class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3'><span lang=EN-US style='font-family:"Arial",sans-serif'>in most cases, it should be easy and cheap to retroactively find those delimiters from the information we do track.<o:p></o:p></span></li></ul><p><span lang=EN-US style='font-family:"Arial",sans-serif'>Furthermore, I think expressions are important to consider,<br>because the practical limitations on finding the semicolon after<br>an expression are exactly the same as finding it after </span><code><span lang=EN-US style='font-size:10.0pt;color:black;background:#F7F7F7'>break</span></code><span lang=EN-US style='font-family:"Arial",sans-serif'>.<br>Fortunately, most of these restrictions coincide with things that<br>are mostly uninteresting to source tools: it’s possible that the<br>semicolon could be inside a macro, but you probably can’t safely<br>rewrite code around macro expansions anyway.<o:p></o:p></span></p><p><span lang=EN-US style='font-family:"Arial",sans-serif'>Now, of course there should be one method that implements this<br>scan instead of forcing it to be re-implemented again and again.<br>That method can have a special case for </span><code><span lang=EN-US style='font-size:10.0pt;color:black;background:#F7F7F7'>NullStmt</span></code><span lang=EN-US style='font-family:"Arial",sans-serif'>.<o:p></o:p></span></p><p><span lang=EN-US style='font-family:"Arial",sans-serif'>John.<o:p></o:p></span></p></div></div></div></body></html>