aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index d3383292f7a3..97c3d86282a0 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -15,6 +15,7 @@
#include "UnwrappedLineParser.h"
#include "FormatToken.h"
#include "TokenAnnotator.h"
+#include "clang/Basic/TokenKinds.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@@ -1910,15 +1911,12 @@ void UnwrappedLineParser::parseStructuralElement(
break;
auto OneTokenSoFar = [&]() {
- const UnwrappedLineNode *Tok = &Line->Tokens.front(),
- *End = Tok + Line->Tokens.size();
- while (Tok != End && Tok->Tok->is(tok::comment))
- ++Tok;
- // In Verilog, macro invocations start with a backtick which the code
- // treats as a hash. Skip it.
- if (Style.isVerilog() && Tok != End && Tok->Tok->is(tok::hash))
- ++Tok;
- return End - Tok == 1;
+ auto I = Line->Tokens.begin(), E = Line->Tokens.end();
+ while (I != E && I->Tok->is(tok::comment))
+ ++I;
+ while (I != E && Style.isVerilog() && I->Tok->is(tok::hash))
+ ++I;
+ return I != E && (++I == E);
};
if (OneTokenSoFar()) {
if (FormatTok->is(tok::colon) && !Line->MustBeDeclaration) {