summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/BreakableToken.cpp
diff options
context:
space:
mode:
authorEric Liu <ioeric@google.com>2016-10-19 08:19:46 +0000
committerEric Liu <ioeric@google.com>2016-10-19 08:19:46 +0000
commit99eeab7ff3aca9a2e0827349b5ce2e7c71a69373 (patch)
tree71652a10b661bb04dbe7832be0b200f6a878c524 /clang/lib/Format/BreakableToken.cpp
parent3f5111d363b4b4829445e8b251cf28b9bd53164e (diff)
downloadbcm5719-llvm-99eeab7ff3aca9a2e0827349b5ce2e7c71a69373.tar.gz
bcm5719-llvm-99eeab7ff3aca9a2e0827349b5ce2e7c71a69373.zip
[clang-format] Add comment manipulation header
Summary: Introduces a separate target for comment manipulation. Currently, comment manipulation is in BreakableComment.cpp. Towards implementing comment reflowing, we want to factor out the comment-related functionality, so it can be reused. Start simple by just moving out getLineCommentIndentPrefix. Patch by Krasimir Georgiev! Reviewers: djasper Subscribers: klimek, beanz, mgorny, modocache Differential Revision: https://reviews.llvm.org/D25725 llvm-svn: 284573
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r--clang/lib/Format/BreakableToken.cpp16
1 files changed, 1 insertions, 15 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index 36a8c4d8da6..6363f895f95 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "BreakableToken.h"
+#include "Comments.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Format/Format.h"
#include "llvm/ADT/STLExtras.h"
@@ -182,21 +183,6 @@ void BreakableStringLiteral::insertBreak(unsigned LineIndex,
Prefix, InPPDirective, 1, IndentLevel, LeadingSpaces);
}
-static StringRef getLineCommentIndentPrefix(StringRef Comment) {
- static const char *const KnownPrefixes[] = {"///", "//", "//!"};
- StringRef LongestPrefix;
- for (StringRef KnownPrefix : KnownPrefixes) {
- if (Comment.startswith(KnownPrefix)) {
- size_t PrefixLength = KnownPrefix.size();
- while (PrefixLength < Comment.size() && Comment[PrefixLength] == ' ')
- ++PrefixLength;
- if (PrefixLength > LongestPrefix.size())
- LongestPrefix = Comment.substr(0, PrefixLength);
- }
- }
- return LongestPrefix;
-}
-
BreakableLineComment::BreakableLineComment(
const FormatToken &Token, unsigned IndentLevel, unsigned StartColumn,
bool InPPDirective, encoding::Encoding Encoding, const FormatStyle &Style)
OpenPOWER on IntegriCloud