[PATCH] D90335: [NFC][FileCheck] Add --allow-unused-prefixes option

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 28 12:26:39 PDT 2020


mtrofin created this revision.
mtrofin added reviewers: MaskRay, jhenderson, jdoerfert, dblaikie.
Herald added subscribers: llvm-commits, thopre.
Herald added a project: LLVM.
mtrofin requested review of this revision.

This introduces the option and plumbs it through, but does not leverage
it just yet.

The background is: FileCheck only checks that one prefix is used, so if
more are specified, some may never be exercised. This may be intentional
or accidental. We want to catch the latter. Currently there are ~1500
tests exhibiting this. The option allows tests to opt in to the behavior
(if that is intended), following which, we enable strict prefix checking
(D90281 <https://reviews.llvm.org/D90281>)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90335

Files:
  llvm/include/llvm/FileCheck/FileCheck.h
  llvm/utils/FileCheck/FileCheck.cpp


Index: llvm/utils/FileCheck/FileCheck.cpp
===================================================================
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -77,6 +77,10 @@
     cl::desc("Allow the input file to be empty. This is useful when making\n"
              "checks that some error message does not occur, for example."));
 
+static cl::opt<bool> AllowUnusedPrefixes(
+    "allow-unused-prefixes", cl::init(false),
+    cl::desc("Allow prefixes to be specified but not appear in the test."));
+
 static cl::opt<bool> MatchFullLines(
     "match-full-lines", cl::init(false),
     cl::desc("Require all positive matches to cover an entire input line.\n"
@@ -771,6 +775,7 @@
     return 2;
 
   Req.AllowEmptyInput = AllowEmptyInput;
+  Req.AllowUnusedPrefixes = AllowUnusedPrefixes;
   Req.EnableVarScope = EnableVarScope;
   Req.AllowDeprecatedDagOverlap = AllowDeprecatedDagOverlap;
   Req.Verbose = Verbose;
Index: llvm/include/llvm/FileCheck/FileCheck.h
===================================================================
--- llvm/include/llvm/FileCheck/FileCheck.h
+++ llvm/include/llvm/FileCheck/FileCheck.h
@@ -30,6 +30,7 @@
   std::vector<StringRef> ImplicitCheckNot;
   std::vector<StringRef> GlobalDefines;
   bool AllowEmptyInput = false;
+  bool AllowUnusedPrefixes = false;
   bool MatchFullLines = false;
   bool IgnoreCase = false;
   bool IsDefaultCheckPrefix = false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90335.301386.patch
Type: text/x-patch
Size: 1426 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201028/46c91b05/attachment.bin>


More information about the llvm-commits mailing list