[llvm] 685fe09 - [FileCheck] Extract new tests for braced search ranges here (#199063)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 05:43:37 PDT 2026


Author: Joel E. Denny
Date: 2026-06-26T08:43:32-04:00
New Revision: 685fe091f93d5d434e7670d1ae91a0df690036f6

URL: https://github.com/llvm/llvm-project/commit/685fe091f93d5d434e7670d1ae91a0df690036f6
DIFF: https://github.com/llvm/llvm-project/commit/685fe091f93d5d434e7670d1ae91a0df690036f6.diff

LOG: [FileCheck] Extract new tests for braced search ranges here (#199063)

This patch introduces several tests in
`llvm/test/FileCheck/dump-input/search-range-annotations` to demonstrate
use cases that PR #198138 improves.

Added: 
    llvm/test/FileCheck/dump-input/search-range-annotations/check-label-follows.txt
    llvm/test/FileCheck/dump-input/search-range-annotations/check-next-same.txt
    llvm/test/FileCheck/dump-input/search-range-annotations/check-not.txt

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/FileCheck/dump-input/search-range-annotations/check-label-follows.txt b/llvm/test/FileCheck/dump-input/search-range-annotations/check-label-follows.txt
new file mode 100644
index 0000000000000..08b266a37aa37
--- /dev/null
+++ b/llvm/test/FileCheck/dump-input/search-range-annotations/check-label-follows.txt
@@ -0,0 +1,67 @@
+; Because -dump-input-filter=error includes a failed directive's search range
+; end, input line 15 below is revealed, and -dump-input-context=2 reveals the
+; surrounding lines.  Those lines are where the actual problem is: the "host
+; triples:" header is off by one.  Sometimes the key to understanding a
+; directive's failure is where the following CHECK-LABEL matched because it
+; limits the search range.  FIXME: Of course, those lines will not be revealed
+; until braced search ranges are actually implemented.
+
+RUN: rm -rf %t
+RUN: split-file %s %t
+
+RUN: %ProtectFileCheckOutput \
+RUN: not FileCheck -dump-input-context=2 -v %t/check.txt < %t/input.txt \
+RUN:               -dump-input-filter=error 2>&1 | \
+RUN:   FileCheck %s -match-full-lines -check-prefix=DMP
+
+     DMP:<<<<<<
+DMP-NEXT:           1: offload triples: 
+DMP-NEXT:label:1'0     ^~~~~~~~~~~~~~~~
+DMP-NEXT:label:1'1     ^~~~~~~~~~~~~~~~
+DMP-NEXT:check:2'0                     X  error: no match found
+DMP-NEXT:           2: - x86_64-linux-gnu 
+DMP-NEXT:check:2'0     ~~~~~~~~~~~~~~~~~~~
+DMP-NEXT:check:2'1       ?                  possible intended match
+DMP-NEXT:           3: - x86_64-unknown-linux-gnu 
+DMP-NEXT:check:2'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+DMP-NEXT:           4: - x86_64-pc-linux-gnu 
+DMP-NEXT:check:2'0     ~~~~~~~~~~~~~~~~~~~~~~
+DMP-NEXT:           .
+DMP-NEXT:           .
+DMP-NEXT:           .
+DMP-NEXT:>>>>>>
+
+;--- check.txt
+CHECK-LABEL: offload triples:
+      CHECK: nvptx64-nvidia-cuda
+CHECK-LABEL: host triples:
+
+;--- input.txt
+offload triples:
+- x86_64-linux-gnu
+- x86_64-unknown-linux-gnu
+- x86_64-pc-linux-gnu
+- x86_64-redhat-linux6E
+- x86_64-redhat-linux
+- x86_64-suse-linux
+- x86_64-manbo-linux-gnu
+- x86_64-linux-gnu
+- x86_64-slackware-linux
+- x86_64-unknown-linux
+- x86_64-amazon-linux
+- x86_64-linux-android
+- amdgcn-amd-amdhsa
+host triples:
+- nvptx64-nvidia-cuda
+- x86_64-linux-gnu
+- x86_64-unknown-linux-gnu
+- x86_64-pc-linux-gnu
+- x86_64-redhat-linux6E
+- x86_64-redhat-linux
+- x86_64-suse-linux
+- x86_64-manbo-linux-gnu
+- x86_64-linux-gnu
+- x86_64-slackware-linux
+- x86_64-unknown-linux
+- x86_64-amazon-linux
+- x86_64-linux-android

diff  --git a/llvm/test/FileCheck/dump-input/search-range-annotations/check-next-same.txt b/llvm/test/FileCheck/dump-input/search-range-annotations/check-next-same.txt
new file mode 100644
index 0000000000000..bfb4a8fa5305b
--- /dev/null
+++ b/llvm/test/FileCheck/dump-input/search-range-annotations/check-next-same.txt
@@ -0,0 +1,54 @@
+; Because -dump-input-filter=error includes a failed directive's search range
+; start, input line 1 below is revealed, and -dump-input-context=2 reveals lines
+; 2-3.  Those lines are where the actual problem is because that is where the
+; CHECK-NEXT/CHECK-SAME directive was expected to match but did not.  The line
+; where CHECK-NEXT/CHECK-SAME actually matched, line 13, is typically less
+; useful information.  FIXME: Of course, the former lines will not be revealed
+; until braced search ranges are actually implemented.
+
+RUN: rm -rf %t
+RUN: split-file %s %t
+
+RUN: %ProtectFileCheckOutput \
+RUN: not FileCheck -dump-input-context=2 -v %t/next.txt < %t/input.txt \
+RUN:               -dump-input-filter=error 2>&1 | \
+RUN:   FileCheck %s -match-full-lines -check-prefixes=DMP,DMP_NEXT
+
+RUN: %ProtectFileCheckOutput \
+RUN: not FileCheck -dump-input-context=2 -v %t/same.txt < %t/input.txt \
+RUN:               -dump-input-filter=error 2>&1 | \
+RUN:   FileCheck %s -match-full-lines -check-prefixes=DMP,DMP_SAME
+
+          DMP:<<<<<<
+     DMP-NEXT:        .
+     DMP-NEXT:        .
+     DMP-NEXT:        .
+     DMP-NEXT:       11: foo9 
+     DMP-NEXT:       12: foo10 
+     DMP-NEXT:       13: end 
+DMP_NEXT-NEXT:next:2     !~~   error: match on wrong line
+DMP_SAME-NEXT:same:2     !~~   error: match on wrong line
+     DMP-NEXT:>>>>>>
+
+;--- next.txt
+CHECK: start
+CHECK-NEXT: end
+
+;--- same.txt
+CHECK: start
+CHECK-SAME: end
+
+;--- input.txt
+start
+foo0
+foo1
+foo2
+foo3
+foo4
+foo5
+foo6
+foo7
+foo8
+foo9
+foo10
+end

diff  --git a/llvm/test/FileCheck/dump-input/search-range-annotations/check-not.txt b/llvm/test/FileCheck/dump-input/search-range-annotations/check-not.txt
new file mode 100644
index 0000000000000..96f8705e71a7b
--- /dev/null
+++ b/llvm/test/FileCheck/dump-input/search-range-annotations/check-not.txt
@@ -0,0 +1,101 @@
+; Because -dump-input-filter=error includes a failed directive's search range,
+; input lines 1 and 62 below are revealed, and -dump-input-context=2 reveals the
+; surrounding lines.  Even with only line 1, it looks like the host list
+; includes a GPU triple.  Line 62 and its context reveals we have an
+; accidentally nested list.  Often the key to understanding a CHECK-NOT failure
+; is where the directives before and after it matched because those establish
+; the search range.  FIXME: Of course, those lines will not be revealed until
+; braced search ranges are actually implemented.
+
+RUN: rm -rf %t
+RUN: split-file %s %t
+
+RUN: %ProtectFileCheckOutput \
+RUN: not FileCheck -dump-input-context=2 -v %t/check.txt < %t/input.txt \
+RUN:               -dump-input-filter=error 2>&1 | \
+RUN:   FileCheck %s -match-full-lines -check-prefix=DMP
+
+     DMP:<<<<<<
+DMP-NEXT:       .
+DMP-NEXT:       .
+DMP-NEXT:       .
+DMP-NEXT:      42:  x86_64-amazon-linux 
+DMP-NEXT:      43:  x86_64-linux-android 
+DMP-NEXT:      44:  nvptx64-nvidia-cuda 
+DMP-NEXT:not:2      !~~~~~~~~~~~~~~~~~~   error: no match expected
+DMP-NEXT:      45:  i686-linux-gnu 
+DMP-NEXT:      46:  i686-pc-linux-gnu 
+DMP-NEXT:       .
+DMP-NEXT:       .
+DMP-NEXT:       .
+DMP-NEXT:>>>>>>
+
+;--- check.txt
+CHECK: <triples kind="host">
+CHECK-NOT: nvptx64-nvidia-cuda
+CHECK: </triples>
+
+;--- input.txt
+<triples kind="host">
+  x86_64-linux-gnu
+  x86_64-unknown-linux-gnu
+  x86_64-pc-linux-gnu
+  x86_64-redhat-linux6E
+  x86_64-redhat-linux
+  x86_64-suse-linux
+  x86_64-manbo-linux-gnu
+  x86_64-linux-gnu
+  x86_64-slackware-linux
+  x86_64-unknown-linux
+  x86_64-amazon-linux
+  x86_64-linux-android
+  i686-linux-gnu
+  i686-pc-linux-gnu
+  i486-linux-gnu
+  i386-linux-gnu
+  i386-redhat-linux6E
+  i686-redhat-linux
+  i586-redhat-linux
+  i386-redhat-linux
+  i586-suse-linux
+  i486-slackware-linux
+  i686-montavista-linux
+  i586-linux-gnu
+  i686-linux-android
+  i386-gnu
+  i486-gnu
+  i586-gnu
+  i686-gnu
+<triples kind="offload">
+  x86_64-linux-gnu
+  x86_64-unknown-linux-gnu
+  x86_64-pc-linux-gnu
+  x86_64-redhat-linux6E
+  x86_64-redhat-linux
+  x86_64-suse-linux
+  x86_64-manbo-linux-gnu
+  x86_64-linux-gnu
+  x86_64-slackware-linux
+  x86_64-unknown-linux
+  x86_64-amazon-linux
+  x86_64-linux-android
+  nvptx64-nvidia-cuda
+  i686-linux-gnu
+  i686-pc-linux-gnu
+  i486-linux-gnu
+  i386-linux-gnu
+  i386-redhat-linux6E
+  i686-redhat-linux
+  i586-redhat-linux
+  i386-redhat-linux
+  i586-suse-linux
+  i486-slackware-linux
+  i686-montavista-linux
+  i586-linux-gnu
+  i686-linux-android
+  i386-gnu
+  i486-gnu
+  i586-gnu
+  i686-gnu
+</triples>
+</triples>


        


More information about the llvm-commits mailing list