From: Benjamin Kramer Date: Mon, 11 Apr 2016 12:19:19 +0000 (+0000) Subject: [clang-format] Walk backwards from end() instead of forwards from rend(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88a4cc02859e9dc8bbaa99060060ea4b23fed8ec;p=clang [clang-format] Walk backwards from end() instead of forwards from rend(). This should've been forwards from rbegin(), reverse iterators are just too confusing to be used by mere mortals. Fixes out-of-bounds walks over the list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265934 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index b25abeae93..76e87768bc 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -718,7 +718,7 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() { if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) { // If the token before the previous one is an '@', the previous token is an // annotation and can precede another identifier/value. - const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok; + const FormatToken *PrePrevious = std::prev(Line->Tokens.end(), 2)->Tok; if (PrePrevious->is(tok::at)) return; }