diff options
author | Jonas Toth <jonas.toth@gmail.com> | 2018-08-24 17:25:06 +0000 |
---|---|---|
committer | Jonas Toth <jonas.toth@gmail.com> | 2018-08-24 17:25:06 +0000 |
commit | 90d2aa233533c7db5da04552a6ba157c29a6fcb9 (patch) | |
tree | b5601943bb3fab4af48bfbbbc1336e26a83e62f8 /clang/lib/Format/UnwrappedLineParser.cpp | |
parent | 4636debc271f09f730697ab6873137a657c828f9 (diff) | |
download | bcm5719-llvm-90d2aa233533c7db5da04552a6ba157c29a6fcb9.tar.gz bcm5719-llvm-90d2aa233533c7db5da04552a6ba157c29a6fcb9.zip |
[clang-format] fix PR38557 - comments between "default" and ':' causes the case label to be treated as an identifier
Summary:
The Bug was reported and fixed by Owen Pan. See the original bug report here: https://bugs.llvm.org/show_bug.cgi?id=38557
Patch by Owen Pan!
Reviewers: krasimir, djasper, klimek
Reviewed By: klimek
Subscribers: JonasToth, cfe-commits
Differential Revision: https://reviews.llvm.org/D50697
llvm-svn: 340624
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index e5afa1264ab..07109daf6f9 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -350,7 +350,10 @@ void UnwrappedLineParser::parseLevel(bool HasOpeningBrace) { break; case tok::kw_default: { unsigned StoredPosition = Tokens->getPosition(); - FormatToken *Next = Tokens->getNextToken(); + FormatToken *Next; + do { + Next = Tokens->getNextToken(); + } while (Next && Next->is(tok::comment)); FormatTok = Tokens->setPosition(StoredPosition); if (Next && Next->isNot(tok::colon)) { // default not followed by ':' is not a case label; treat it like |