diff options
author | Tim Northover <tnorthover@apple.com> | 2018-08-03 12:19:22 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2018-08-03 12:19:22 +0000 |
commit | 608f136dbbb3570b61c66478a07b40ad3051fcba (patch) | |
tree | e5595757e47e290a1f95cf66951db8fafb173cdc /clang/lib/Format/BreakableToken.cpp | |
parent | 3a92c5c1d38f045cd199093a84f49bb961b8a64e (diff) | |
download | bcm5719-llvm-608f136dbbb3570b61c66478a07b40ad3051fcba.tar.gz bcm5719-llvm-608f136dbbb3570b61c66478a07b40ad3051fcba.zip |
Revert "clang-format: [JS] don't break comments before any '{'"
This reverts commit r338837, it introduced an infinite loop on all bots.
llvm-svn: 338879
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index bd80de17155..300e3f802cb 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -90,19 +90,19 @@ static BreakableToken::Split getCommentSplit(StringRef Text, StringRef::size_type SpaceOffset = Text.find_last_of(Blanks, MaxSplitBytes); + // Do not split before a number followed by a dot: this would be interpreted + // as a numbered list, which would prevent re-flowing in subsequent passes. static auto *const kNumberedListRegexp = new llvm::Regex("^[1-9][0-9]?\\."); - while (SpaceOffset != StringRef::npos) { - // Do not split before a number followed by a dot: this would be interpreted - // as a numbered list, which would prevent re-flowing in subsequent passes. - if (kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks))) - SpaceOffset = Text.find_last_of(Blanks, SpaceOffset); - // In JavaScript, some @tags can be followed by {, and machinery that parses - // these comments will fail to understand the comment if followed by a line - // break. So avoid ever breaking before a {. - else if (Style.Language == FormatStyle::LK_JavaScript && - SpaceOffset + 1 < Text.size() && Text[SpaceOffset + 1] == '{') - SpaceOffset = Text.find_last_of(Blanks, SpaceOffset); - } + if (SpaceOffset != StringRef::npos && + kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks))) + SpaceOffset = Text.find_last_of(Blanks, SpaceOffset); + // In JavaScript, some @tags can be followed by {, and machinery that parses + // these comments will fail to understand the comment if followed by a line + // break. So avoid ever breaking before a {. + if (Style.Language == FormatStyle::LK_JavaScript && + SpaceOffset != StringRef::npos && SpaceOffset + 1 < Text.size() && + Text[SpaceOffset + 1] == '{') + SpaceOffset = Text.find_last_of(Blanks, SpaceOffset); if (SpaceOffset == StringRef::npos || // Don't break at leading whitespace. |