]> granicus.if.org Git - clang/commitdiff
[format] Eliminate global destructors.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 20 Mar 2018 21:52:19 +0000 (21:52 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 20 Mar 2018 21:52:19 +0000 (21:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328047 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/BreakableToken.cpp
lib/Format/Format.cpp

index 72d2078797e5ab474ecbb1654a85db0fd3f221e3..b603067ab3e5e68eb3c4f9340984e6a8a2d37c76 100644 (file)
@@ -89,9 +89,9 @@ static BreakableToken::Split getCommentSplit(StringRef Text,
 
   // Do not split before a number followed by a dot: this would be interpreted
   // as a numbered list, which would prevent re-flowing in subsequent passes.
-  static llvm::Regex kNumberedListRegexp = llvm::Regex("^[1-9][0-9]?\\.");
+  static auto *const kNumberedListRegexp = new llvm::Regex("^[1-9][0-9]?\\.");
   if (SpaceOffset != StringRef::npos &&
-      kNumberedListRegexp.match(Text.substr(SpaceOffset).ltrim(Blanks)))
+      kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks)))
     SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
 
   if (SpaceOffset == StringRef::npos ||
@@ -284,10 +284,9 @@ static bool mayReflowContent(StringRef Content) {
   Content = Content.trim(Blanks);
   // Lines starting with '@' commonly have special meaning.
   // Lines starting with '-', '-#', '+' or '*' are bulleted/numbered lists.
-  static const SmallVector<StringRef, 8> kSpecialMeaningPrefixes = {
-      "@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "};
   bool hasSpecialMeaningPrefix = false;
-  for (StringRef Prefix : kSpecialMeaningPrefixes) {
+  for (StringRef Prefix :
+       {"@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "}) {
     if (Content.startswith(Prefix)) {
       hasSpecialMeaningPrefix = true;
       break;
@@ -297,9 +296,9 @@ static bool mayReflowContent(StringRef Content) {
   // Numbered lists may also start with a number followed by '.'
   // To avoid issues if a line starts with a number which is actually the end
   // of a previous line, we only consider numbers with up to 2 digits.
-  static llvm::Regex kNumberedListRegexp = llvm::Regex("^[1-9][0-9]?\\. ");
+  static auto *const kNumberedListRegexp = new llvm::Regex("^[1-9][0-9]?\\. ");
   hasSpecialMeaningPrefix =
-      hasSpecialMeaningPrefix || kNumberedListRegexp.match(Content);
+      hasSpecialMeaningPrefix || kNumberedListRegexp->match(Content);
 
   // Simple heuristic for what to reflow: content should contain at least two
   // characters and either the first or second character must be
index 5c7ce8517832a9ccd99532fb1e549fa2160d28ee..69b3881a7ac5837f288f1b742ddb206980e60106 100644 (file)
@@ -511,7 +511,7 @@ namespace clang {
 namespace format {
 
 const std::error_category &getParseCategory() {
-  static ParseErrorCategory C;
+  static const ParseErrorCategory C{};
   return C;
 }
 std::error_code make_error_code(ParseError e) {