]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/Format/Comments.cpp
Update clang to trunk r290819 and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / Format / Comments.cpp
1 //===--- Comments.cpp - Comment Manipulation  -------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Implements comment manipulation.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "Comments.h"
16
17 namespace clang {
18 namespace format {
19
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] == ' ')
27         ++PrefixLength;
28       if (PrefixLength > LongestPrefix.size())
29         LongestPrefix = Comment.substr(0, PrefixLength);
30     }
31   }
32   return LongestPrefix;
33 }
34
35 } // namespace format
36 } // namespace clang