Skip to content

Commit

Permalink
[FileCheck] Default --allow-unused-prefixes to false
Browse files Browse the repository at this point in the history
Link: https://lists.llvm.org/pipermail/llvm-dev/2020-October/146162.html "[RFC] FileCheck: (dis)allowing unused prefixes"

If a downstream project using lit needs time for transition,
add the following to `lit.local.cfg`:

```
from lit.llvm.subst import ToolSubst

fc = ToolSubst('FileCheck', unresolved='fatal')
config.substitutions.insert(0, (fc.regex, 'FileCheck --allow-unused-prefixes'))
```

Differential Revision: https://reviews.llvm.org/D95849
  • Loading branch information
MaskRay committed Feb 8, 2021
1 parent ad60802 commit 87dbdd2
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 61 deletions.
2 changes: 1 addition & 1 deletion clang/test/Driver/crash-report-null.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: env FORCE_CLANG_DIAGNOSTICS_CRASH=1 not %clang -fsyntax-only -x c /dev/null -lstdc++ 2>&1 | FileCheck %s

// FIXME: Investigating. "fatal error: file 'nul' modified since it was first processed"
// XFAIL: windows-gnu
// UNSUPPORTED: system-windows

// CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script.
// CHECK: Preprocessed source(s) and associated run script(s) are located at:
Expand Down
7 changes: 1 addition & 6 deletions clang/test/OpenMP/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,4 @@
from lit.llvm.subst import ToolSubst

fc = ToolSubst('FileCheck', unresolved='fatal')
# the parent introduced the opposite rule, so we replace it if we see it.
if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 'FileCheck --allow-unused-prefixes=false'):
config.substitutions[0] = (
fc.regex, 'FileCheck --allow-unused-prefixes=true')
else:
config.substitutions.insert(0, (fc.regex, 'FileCheck --allow-unused-prefixes=true'))
config.substitutions.insert(0, (fc.regex, 'FileCheck --allow-unused-prefixes'))
8 changes: 0 additions & 8 deletions clang/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@

llvm_config.use_clang()

# FIXME: remove this when we flip the default value for --allow-unused-prefixes
# to false.
fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))

config.substitutions.append(
('%src_include_dir', config.clang_src_dir + '/include'))

Expand Down
5 changes: 1 addition & 4 deletions llvm/test/FileCheck/allow-unused-prefixes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
; RUN: %ProtectFileCheckOutput not FileCheck --allow-unused-prefixes=false --check-prefixes=P1,P2,P3 --input-file %S/Inputs/one-check.txt %S/Inputs/one-check.txt 2>&1 | FileCheck --check-prefix=MISSING-MORE %s
; RUN: FileCheck --allow-unused-prefixes=true --check-prefixes=P1,P2 --input-file %S/Inputs/one-check.txt %S/Inputs/one-check.txt
; RUN: FileCheck --allow-unused-prefixes=false --allow-unused-prefixes=true --check-prefixes=P1,P2 --input-file %S/Inputs/one-check.txt %S/Inputs/one-check.txt

;; Note: the default will be changed to 'false', at which time this run line
;; should be changed accordingly.
; RUN: FileCheck --check-prefixes=P1,P2 --input-file %S/Inputs/one-check.txt %S/Inputs/one-check.txt
; RUN: not FileCheck --check-prefixes=P1,P2 --input-file %S/Inputs/one-check.txt %S/Inputs/one-check.txt

; MISSING-ONE: error: no check strings found with prefix 'P2:'
; MISSING-MORE: error: no check strings found with prefixes 'P2:', 'P3:'
9 changes: 0 additions & 9 deletions llvm/test/FileCheck/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,3 @@ config.test_format = lit.formats.ShTest(execute_external=False)
# that test results throughout all test suites are affected.
config.substitutions.append(('%ProtectFileCheckOutput',
'env -u FILECHECK_OPTS'))

# FIXME: remove this once the default is flipped.
from lit.llvm.subst import ToolSubst

fc = ToolSubst('FileCheck', unresolved='fatal')
# the parent introduced the opposite rule, so we replace it if we see it.
if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 'FileCheck --allow-unused-prefixes=false'):
del config.substitutions[0]

2 changes: 1 addition & 1 deletion llvm/test/Other/opt-bisect-legacy-pass-manager.ll
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
; f2() in f3().

; RUN: %python %S/opt-bisect-helper.py --start=0 --end=256 --optcmd=opt \
; RUN: --filecheckcmd=%FileCheckRaw% --test=%s \
; RUN: --filecheckcmd=FileCheck --test=%s \
; RUN: --prefix=CHECK-BISECT-INLINE-HELPER \
; RUN: | FileCheck %s --check-prefix=CHECK-BISECT-INLINE-RESULT
; The helper script uses this to find the optimization that inlines the call.
Expand Down
8 changes: 0 additions & 8 deletions llvm/test/Reduce/lit.local.cfg

This file was deleted.

8 changes: 1 addition & 7 deletions llvm/test/Transforms/Attributor/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@
from lit.llvm.subst import ToolSubst

fc = ToolSubst('FileCheck', unresolved='fatal')
# the parent introduced the opposite rule, so we replace it if we see it.
if len(config.substitutions) > 0 and config.substitutions[0] == (fc.regex, 'FileCheck --allow-unused-prefixes=false'):
config.substitutions[0] = (
fc.regex, 'FileCheck --allow-unused-prefixes=true')
else:
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=true'))
config.substitutions.insert(0, (fc.regex, 'FileCheck --allow-unused-prefixes'))
18 changes: 2 additions & 16 deletions llvm/test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,6 @@ def get_asan_rtlib():
return found_dylibs[0]


####################################################
# FIXME: remove this when we flip the default value for --allow-unused-prefixes
# to false.
fc = ToolSubst('FileCheck', unresolved='fatal')
# Insert this first. Then, we'll first update the blank FileCheck command; then,
# the default substitution of FileCheck will replace it to its full path.
config.substitutions.insert(0, (fc.regex,
'FileCheck --allow-unused-prefixes=false'))
# When addressing this fixme, replace %FileCheckRaw% with just FileCheck.
config.substitutions.append(('%FileCheckRaw%', 'FileCheck'))
# Also remove the lit.local.cfg under llvm/test/Reduce
# and the pertinent FIXME in llvm/test/FileCheck
####################################################

llvm_config.use_default_substitutions()

# Add site-specific substitutions.
Expand Down Expand Up @@ -162,8 +148,8 @@ def get_asan_rtlib():
# FIXME: Why do we have both `lli` and `%lli` that do slightly different things?
tools.extend([
'dsymutil', 'lli', 'lli-child-target', 'llvm-ar', 'llvm-as',
'llvm-addr2line', 'llvm-bcanalyzer', 'llvm-bitcode-strip', 'llvm-config',
'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis',
'llvm-addr2line', 'llvm-bcanalyzer', 'llvm-bitcode-strip', 'llvm-config',
'llvm-cov', 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis',
'llvm-dwarfdump', 'llvm-dlltool', 'llvm-exegesis', 'llvm-extract',
'llvm-isel-fuzzer', 'llvm-ifs',
'llvm-install-name-tool', 'llvm-jitlink', 'llvm-opt-fuzzer', 'llvm-lib',
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/FileCheck/FileCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static cl::opt<bool> AllowEmptyInput(
"checks that some error message does not occur, for example."));

static cl::opt<bool> AllowUnusedPrefixes(
"allow-unused-prefixes", cl::init(true), cl::ZeroOrMore,
"allow-unused-prefixes", cl::init(false), cl::ZeroOrMore,
cl::desc("Allow prefixes to be specified but not appear in the test."));

static cl::opt<bool> MatchFullLines(
Expand Down

0 comments on commit 87dbdd2

Please sign in to comment.