1 //===--- Comments.cpp - Comment Manipulation -------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Implements comment manipulation.
13 //===----------------------------------------------------------------------===//
20 StringRef getLineCommentIndentPrefix(StringRef Comment) {
21 static const char *const KnownPrefixes[] = {"///", "//", "//!"};
22 StringRef LongestPrefix;
23 for (StringRef KnownPrefix : KnownPrefixes) {
24 if (Comment.startswith(KnownPrefix)) {
25 size_t PrefixLength = KnownPrefix.size();
26 while (PrefixLength < Comment.size() && Comment[PrefixLength] == ' ')
28 if (PrefixLength > LongestPrefix.size())
29 LongestPrefix = Comment.substr(0, PrefixLength);