[PATCH] D68155: [clang][NFC] Make various uses of Regex const

2019-11-19 Thread Nicolas Guillemot via Phabricator via cfe-commits
nlguillemot added a comment.

In D68155#1751826 , @thopre wrote:

> My sincere apologies, I forgot to change the author in the commit. I don't 
> often commit on behalf of others so didn't think enough.


No worries. Thanks again for helping with the commit!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68155/new/

https://reviews.llvm.org/D68155



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68155: [clang][NFC] Make various uses of Regex const

2019-11-19 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

My sincere apologies, I forgot to change the author in the commit. I don't 
often commit on behalf of others so didn't think enough.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68155/new/

https://reviews.llvm.org/D68155



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68155: [clang][NFC] Make various uses of Regex const

2019-11-19 Thread Thomas Preud'homme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb81cc6032902: [clang][NFC] Make various uses of Regex const 
(authored by thopre).

Changed prior to commit:
  https://reviews.llvm.org/D68155?vs=26=230079#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68155/new/

https://reviews.llvm.org/D68155

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Format/BreakableToken.cpp
  clang/lib/Format/BreakableToken.h
  clang/lib/Format/NamespaceEndCommentsFixer.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/tools/clang-refactor/TestSupport.cpp

Index: clang/tools/clang-refactor/TestSupport.cpp
===
--- clang/tools/clang-refactor/TestSupport.cpp
+++ clang/tools/clang-refactor/TestSupport.cpp
@@ -303,9 +303,10 @@
 
   // See the doc comment for this function for the explanation of this
   // syntax.
-  static Regex RangeRegex("range[[:blank:]]*([[:alpha:]_]*)?[[:blank:]]*=[[:"
-  "blank:]]*(\\+[[:digit:]]+)?[[:blank:]]*(->[[:blank:]"
-  "]*[\\+\\:[:digit:]]+)?");
+  static const Regex RangeRegex(
+  "range[[:blank:]]*([[:alpha:]_]*)?[[:blank:]]*=[[:"
+  "blank:]]*(\\+[[:digit:]]+)?[[:blank:]]*(->[[:blank:]"
+  "]*[\\+\\:[:digit:]]+)?");
 
   std::map> GroupedRanges;
 
@@ -352,7 +353,7 @@
 unsigned EndOffset;
 
 if (!Matches[3].empty()) {
-  static Regex EndLocRegex(
+  static const Regex EndLocRegex(
   "->[[:blank:]]*(\\+[[:digit:]]+):([[:digit:]]+)");
   SmallVector EndLocMatches;
   if (!EndLocRegex.match(Matches[3], )) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2498,9 +2498,10 @@
 
 // Checks if \p FormatTok is a line comment that continues the line comment
 // section on \p Line.
-static bool continuesLineCommentSection(const FormatToken ,
-const UnwrappedLine ,
-llvm::Regex ) {
+static bool
+continuesLineCommentSection(const FormatToken ,
+const UnwrappedLine ,
+const llvm::Regex ) {
   if (Line.Tokens.empty())
 return false;
 
Index: clang/lib/Format/NamespaceEndCommentsFixer.cpp
===
--- clang/lib/Format/NamespaceEndCommentsFixer.cpp
+++ clang/lib/Format/NamespaceEndCommentsFixer.cpp
@@ -92,24 +92,24 @@
 
   // Matches a valid namespace end comment.
   // Valid namespace end comments don't need to be edited.
-  static llvm::Regex *const NamespaceCommentPattern =
-  new llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "namespace( +([a-zA-Z0-9:_]+))?\\.? *(\\*/)?$",
-  llvm::Regex::IgnoreCase);
-  static llvm::Regex *const NamespaceMacroCommentPattern =
-  new llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*)\\)\\.? *(\\*/)?$",
-  llvm::Regex::IgnoreCase);
+  static const llvm::Regex NamespaceCommentPattern =
+  llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
+  "namespace( +([a-zA-Z0-9:_]+))?\\.? *(\\*/)?$",
+  llvm::Regex::IgnoreCase);
+  static const llvm::Regex NamespaceMacroCommentPattern =
+  llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
+  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*)\\)\\.? *(\\*/)?$",
+  llvm::Regex::IgnoreCase);
 
   SmallVector Groups;
   if (NamespaceTok->is(TT_NamespaceMacro) &&
-  NamespaceMacroCommentPattern->match(Comment->TokenText, )) {
+  NamespaceMacroCommentPattern.match(Comment->TokenText, )) {
 StringRef NamespaceTokenText = Groups.size() > 4 ? Groups[4] : "";
 // The name of the macro must be used.
 if (NamespaceTokenText != NamespaceTok->TokenText)
   return false;
   } else if (NamespaceTok->isNot(tok::kw_namespace) ||
- !NamespaceCommentPattern->match(Comment->TokenText, )) {
+ !NamespaceCommentPattern.match(Comment->TokenText, )) {
 // Comment does not match regex.
 return false;
   }
Index: clang/lib/Format/BreakableToken.h
===
--- clang/lib/Format/BreakableToken.h
+++ clang/lib/Format/BreakableToken.h
@@ -155,7 +155,7 @@
   /// file.
   virtual Split getSplit(unsigned LineIndex, unsigned TailOffset,
  unsigned ColumnLimit, unsigned ContentStartColumn,
- llvm::Regex ) const = 0;
+ const llvm::Regex ) const = 0;
 
   /// Emits the previously retrieved \p Split via \p Whitespaces.
   virtual void 

[PATCH] D68155: [clang][NFC] Make various uses of Regex const

2019-11-18 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre accepted this revision.
thopre added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68155/new/

https://reviews.llvm.org/D68155



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D68155: [clang][NFC] Make various uses of Regex const

2019-09-27 Thread Nicolas Guillemot via Phabricator via cfe-commits
nlguillemot created this revision.
nlguillemot added a reviewer: thopre.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The const-correctness of match() was fixed in rL372764 
, which allows
uses of Regex objects to be const in cases they couldn't be before. This
patch tightens up the const-ness of Regex in various such cases.


Repository:
  rC Clang

https://reviews.llvm.org/D68155

Files:
  include/clang/Tooling/Inclusions/HeaderIncludes.h
  lib/Format/BreakableToken.cpp
  lib/Format/BreakableToken.h
  lib/Format/NamespaceEndCommentsFixer.cpp
  lib/Format/UnwrappedLineParser.cpp
  tools/clang-refactor/TestSupport.cpp

Index: tools/clang-refactor/TestSupport.cpp
===
--- tools/clang-refactor/TestSupport.cpp
+++ tools/clang-refactor/TestSupport.cpp
@@ -303,9 +303,10 @@
 
   // See the doc comment for this function for the explanation of this
   // syntax.
-  static Regex RangeRegex("range[[:blank:]]*([[:alpha:]_]*)?[[:blank:]]*=[[:"
-  "blank:]]*(\\+[[:digit:]]+)?[[:blank:]]*(->[[:blank:]"
-  "]*[\\+\\:[:digit:]]+)?");
+  static const Regex RangeRegex(
+  "range[[:blank:]]*([[:alpha:]_]*)?[[:blank:]]*=[[:"
+  "blank:]]*(\\+[[:digit:]]+)?[[:blank:]]*(->[[:blank:]"
+  "]*[\\+\\:[:digit:]]+)?");
 
   std::map> GroupedRanges;
 
@@ -352,7 +353,7 @@
 unsigned EndOffset;
 
 if (!Matches[3].empty()) {
-  static Regex EndLocRegex(
+  static const Regex EndLocRegex(
   "->[[:blank:]]*(\\+[[:digit:]]+):([[:digit:]]+)");
   SmallVector EndLocMatches;
   if (!EndLocRegex.match(Matches[3], )) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -2495,9 +2495,10 @@
 
 // Checks if \p FormatTok is a line comment that continues the line comment
 // section on \p Line.
-static bool continuesLineCommentSection(const FormatToken ,
-const UnwrappedLine ,
-llvm::Regex ) {
+static bool
+continuesLineCommentSection(const FormatToken ,
+const UnwrappedLine ,
+const llvm::Regex ) {
   if (Line.Tokens.empty())
 return false;
 
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -92,24 +92,24 @@
 
   // Matches a valid namespace end comment.
   // Valid namespace end comments don't need to be edited.
-  static llvm::Regex *const NamespaceCommentPattern =
-  new llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "namespace( +([a-zA-Z0-9:_]+))?\\.? *(\\*/)?$",
-  llvm::Regex::IgnoreCase);
-  static llvm::Regex *const NamespaceMacroCommentPattern =
-  new llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*)\\)\\.? *(\\*/)?$",
-  llvm::Regex::IgnoreCase);
+  static const llvm::Regex NamespaceCommentPattern =
+  llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
+  "namespace( +([a-zA-Z0-9:_]+))?\\.? *(\\*/)?$",
+  llvm::Regex::IgnoreCase);
+  static const llvm::Regex NamespaceMacroCommentPattern =
+  llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
+  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*)\\)\\.? *(\\*/)?$",
+  llvm::Regex::IgnoreCase);
 
   SmallVector Groups;
   if (NamespaceTok->is(TT_NamespaceMacro) &&
-  NamespaceMacroCommentPattern->match(Comment->TokenText, )) {
+  NamespaceMacroCommentPattern.match(Comment->TokenText, )) {
 StringRef NamespaceTokenText = Groups.size() > 4 ? Groups[4] : "";
 // The name of the macro must be used.
 if (NamespaceTokenText != NamespaceTok->TokenText)
   return false;
   } else if (NamespaceTok->isNot(tok::kw_namespace) ||
- !NamespaceCommentPattern->match(Comment->TokenText, )) {
+ !NamespaceCommentPattern.match(Comment->TokenText, )) {
 // Comment does not match regex.
 return false;
   }
Index: lib/Format/BreakableToken.h
===
--- lib/Format/BreakableToken.h
+++ lib/Format/BreakableToken.h
@@ -155,7 +155,7 @@
   /// file.
   virtual Split getSplit(unsigned LineIndex, unsigned TailOffset,
  unsigned ColumnLimit, unsigned ContentStartColumn,
- llvm::Regex ) const = 0;
+ const llvm::Regex ) const = 0;
 
   /// Emits the previously retrieved \p Split via \p Whitespaces.
   virtual void insertBreak(unsigned LineIndex, unsigned TailOffset, Split