]> granicus.if.org Git - clang/commitdiff
[clang-format] Walk backwards from end() instead of forwards from rend().
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 11 Apr 2016 12:19:19 +0000 (12:19 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 11 Apr 2016 12:19:19 +0000 (12:19 +0000)
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

lib/Format/UnwrappedLineParser.cpp

index b25abeae937dce4f5678c86e3df04a21cbec8e10..76e87768bc6b96b99d54733c80a581186d40e10b 100644 (file)
@@ -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;
   }