In method 'BracesAroundStatementsCheck::checkStmt' the call 'Lexer::makeFileCharRange(line 253)' return different EndSourceLocation for different statements.
CharSourceRange FileRange = Lexer::makeFileCharRange(
CharSourceRange::getTokenRange(S->getSourceRange()), SM,
Context->getLangOpts());For example
class c {};
c test()
{
if (true)
return {};
if (true)
bool b[2] = { true, true };
}In case
return {};FileRange.getEnd() will be ';'
In case
bool b[2] = { true, true };FileRange.getEnd() will be '\r'
Before call 'findEndLocation' we do this
const auto FREnd = FileRange.getEnd().getLocWithOffset(-1);
so 'findEndLocation' received '}' in the first case and ';' in the second what breaks the logic of 'findEndLocation'.
Could you change this to llvm::Expected<Kind> tryGetTokenKind(SourceLocation Loc, const SourceManager &SM, const ASTContext *Context). From a readability and performance standpoint, returned parameters are generally better than out parameters.