[llvm-branch-commits] [clang] 6cb2887 - [clang-format] [NFC] Use some constexpr StringRef

Björn Schäpers via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jan 25 12:08:13 PST 2021


Author: Björn Schäpers
Date: 2021-01-25T21:02:40+01:00
New Revision: 6cb288797122ad931aba91e05030c24984e1031c

URL: https://github.com/llvm/llvm-project/commit/6cb288797122ad931aba91e05030c24984e1031c
DIFF: https://github.com/llvm/llvm-project/commit/6cb288797122ad931aba91e05030c24984e1031c.diff

LOG: [clang-format] [NFC] Use some constexpr StringRef

Instead of const char*.

Differential Revision: https://reviews.llvm.org/D95078

Added: 
    

Modified: 
    clang/lib/Format/BreakableToken.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index c5edc670393c..d5167c01dc23 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -25,7 +25,7 @@
 namespace clang {
 namespace format {
 
-static const char *const Blanks = " \t\v\f\r";
+static constexpr StringRef Blanks = " \t\v\f\r";
 static bool IsBlank(char C) {
   switch (C) {
   case ' ':
@@ -41,11 +41,11 @@ static bool IsBlank(char C) {
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment,
                                             const FormatStyle &Style) {
-  static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///",
-                                                    "//",   "//!",  "//:"};
-  static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
-                                                       "####"};
-  ArrayRef<const char *> KnownPrefixes(KnownCStylePrefixes);
+  static constexpr StringRef KnownCStylePrefixes[] = {"///<", "//!<", "///",
+                                                      "//",   "//!",  "//:"};
+  static constexpr StringRef KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
+                                                         "####"};
+  ArrayRef<StringRef> KnownPrefixes(KnownCStylePrefixes);
   if (Style.Language == FormatStyle::LK_TextProto)
     KnownPrefixes = KnownTextProtoPrefixes;
 


        


More information about the llvm-branch-commits mailing list