[PATCH] D98343: [FileCheck] Fix checkWildcardRegexCharMatchFailure API

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 10 06:16:47 PST 2021


thopre created this revision.
thopre added a reviewer: jdenny.
Herald added a subscriber: kristof.beyls.
thopre requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

checkWildcardRegexCharMatchFailure uses its parameter as a sequence of
characters yet the parameter has type StringRef. This commit changes
that to SmallVector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98343

Files:
  llvm/unittests/FileCheck/FileCheckTest.cpp


Index: llvm/unittests/FileCheck/FileCheckTest.cpp
===================================================================
--- llvm/unittests/FileCheck/FileCheckTest.cpp
+++ llvm/unittests/FileCheck/FileCheckTest.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/FileCheck/FileCheck.h"
 #include "../lib/FileCheck/FileCheckImpl.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
@@ -100,9 +101,9 @@
   std::string MaxUint64Str;
   std::string MaxInt64Str;
   std::string MinInt64Str;
-  StringRef FirstInvalidCharDigits;
+  SmallVector<char> FirstInvalidCharDigits;
   StringRef AcceptedHexOnlyDigits;
-  StringRef RefusedHexOnlyDigits;
+  SmallVector<char> RefusedHexOnlyDigits;
 
   SourceMgr SM;
 
@@ -121,8 +122,7 @@
       MinInt64Str = std::to_string(MinInt64);
       TenStr = "10";
       FifteenStr = "15";
-      FirstInvalidCharDigits = "aA";
-      AcceptedHexOnlyDigits = RefusedHexOnlyDigits = "N/A";
+      FirstInvalidCharDigits = {'a', 'A'};
       return;
     }
 
@@ -131,9 +131,12 @@
     TenStr = AllowUpperHex ? "A" : "a";
     FifteenStr = AllowUpperHex ? "F" : "f";
     AcceptedHexOnlyDigits = AllowUpperHex ? "ABCDEF" : "abcdef";
-    RefusedHexOnlyDigits = AllowUpperHex ? "abcdef" : "ABCDEF";
+    if (AllowUpperHex)
+      RefusedHexOnlyDigits = {'a', 'b', 'c', 'd', 'e', 'f'};
+    else
+      RefusedHexOnlyDigits = {'A', 'B', 'C', 'D', 'E', 'F'};
     MinInt64Str = "N/A";
-    FirstInvalidCharDigits = "gG";
+    FirstInvalidCharDigits = {'g', 'G'};
   }
 
   void checkWildcardRegexMatch(StringRef Input,
@@ -152,7 +155,7 @@
     EXPECT_FALSE(WildcardRegex.match(Input));
   }
 
-  void checkWildcardRegexCharMatchFailure(StringRef Chars) const {
+  void checkWildcardRegexCharMatchFailure(SmallVectorImpl<char> &Chars) const {
     for (auto C : Chars)
       EXPECT_FALSE(WildcardRegex.match(StringRef(&C, 1)));
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98343.329641.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210310/6ab921b3/attachment.bin>


More information about the llvm-commits mailing list