================
Comment at: clang-tidy/misc/BracesAroundStatementsCheck.cpp:71
@@ +70,3 @@
+ //SourceLocation EndLoc = S->getLocEnd().getLocWithOffset(1 + Offset); //
passes unittests
+ SourceLocation EndLoc = S->getLocEnd().getLocWithOffset(2); // passes tests
+ auto Diag = diag(S->getLocStart(), "statement should be inside braces");
----------------
alexfh wrote:
> Both options are wrong. You don't need to specify Offset explicitly.
> getLocEnd() returns the location of the first character of the last token, so
> you need to use Lexer::getLocForEndOfToken(S->getLocEnd()), which will get
> you a location right after the last token of the statement.
>
> Also, if there's an else/while();, I'd better you put the closing brace right
> before them in case there are comments between the statement and
> else/while();.
>
> Addressing this and the next comment will make it possible to maintain the
> LLVM-like style of arranging braces even without reformatting the changes.
And of course I meant:
SourceLocation EndLoc = Lexer::getLocForEndOfToken(
S->getLocEnd(), 0, *Result.SourceManager,
Result.Context->getLangOpts());
http://reviews.llvm.org/D5395
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits