I’m having trouble with the locations returned by Stmt getEndLoc()/getSourceRange() and am wondering whether this is a bug/flaw:
the returned location sometimes includes and sometimes excludes the semicolon in the end.
This gets even more interesting when there are (multiple) comments before the semicolon, simply because the difference between the returned values gets even bigger.
Here is an example showing how DeclStmt includes the semicolon, while CallExpr and BinaryOperator exclude the semicolon http://ce.steveire.com/z/TW3IAG.
So Stmt behaves “completely differently” depending on it’s type, which is no way suggested by it’s interface.
Wouldn’t it be better for Stmt-Users if it would always be the same?
(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)
Here is one of the effects of this complexity for users of Stmt as they struggle to find that semicolon:
Of course it’s fixable there, but that would imply working around the issue in multiple places.