<html 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:"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:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=DE link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-GB>Hello,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>I’m having trouble with the locations returned by Stmt getEndLoc()/getSourceRange() and am wondering whether this is a bug/flaw:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>the returned location sometimes includes and sometimes excludes the semicolon in the end.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>This gets even more interesting when there are (multiple) comments before the semicolon, simply because the difference between the returned values gets even bigger.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Here is an example showing how DeclStmt includes the semicolon, while CallExpr and BinaryOperator exclude the semicolon <a href="http://ce.steveire.com/z/TW3IAG">http://ce.steveire.com/z/TW3IAG</a>.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>So Stmt behaves “completely differently” depending on it’s type, which is no way suggested by it’s interface.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Wouldn’t it be better for Stmt-Users if it would always be the same?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>(Not sure whether it should always be included or excluded. It’s not even always a semicolon as in that 3rd foo() in the example)<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><a href="https://en.wikipedia.org/wiki/Liskov_substitution_principle">https://en.wikipedia.org/wiki/Liskov_substitution_principle</a><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Here is one of the effects of this complexity for users of Stmt as they struggle to find that semicolon:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><a href="https://bugs.llvm.org/show_bug.cgi?id=25970">https://bugs.llvm.org/show_bug.cgi?id=25970</a> / <a href="https://reviews.llvm.org/D16267">https://reviews.llvm.org/D16267</a><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Of course it’s fixable there, but that would imply working around the issue in multiple places.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB>Regards,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB>Alexander Lanin<o:p></o:p></span></p></div></body></html>