diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-02-02 10:52:08 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-02-02 10:52:08 +0000 |
commit | f65fd02738363bce0f094c4351788fd0bd5b73c1 (patch) | |
tree | 2e65eae9283225f67073d98390ba38b10fbe6b00 /lib/Format/BreakableToken.cpp | |
parent | 49ab8e4b60491e33f35d33ba9d7be9259ed01b0f (diff) |
[clang-format] Don't reflow lines starting with TODO, FIXME or XXX.
Summary: These lines commonly carry a special meaning.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D29396
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@293878 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/BreakableToken.cpp')
-rw-r--r-- | lib/Format/BreakableToken.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index 0141e2381d..09f17a35d0 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -301,12 +301,21 @@ const FormatToken &BreakableComment::tokenAt(unsigned LineIndex) const { static bool mayReflowContent(StringRef Content) { Content = Content.trim(Blanks); + // Lines starting with '@' commonly have special meaning. + static const SmallVector<StringRef, 4> kSpecialMeaningPrefixes = { + "@", "TODO", "FIXME", "XXX"}; + bool hasSpecialMeaningPrefix = false; + for (StringRef Prefix : kSpecialMeaningPrefixes) { + if (Content.startswith(Prefix)) { + hasSpecialMeaningPrefix = true; + break; + } + } // Simple heuristic for what to reflow: content should contain at least two // characters and either the first or second character must be // non-punctuation. - return Content.size() >= 2 && - // Lines starting with '@' commonly have special meaning. - !Content.startswith("@") && !Content.endswith("\\") && + return Content.size() >= 2 && !hasSpecialMeaningPrefix && + !Content.endswith("\\") && // Note that this is UTF-8 safe, since if isPunctuation(Content[0]) is // true, then the first code point must be 1 byte long. (!isPunctuation(Content[0]) || !isPunctuation(Content[1])); |