[FileCheck] Default --allow-unused-prefixes to false

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
This commit is contained in:
Fangrui Song 2021-02-08 13:37:03 -08:00
parent ad60802a71
commit 87dbdd2e3b
10 changed files with 8 additions and 61 deletions

View File

@ -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:

View File

@ -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'))

View File

@ -43,14 +43,6 @@ llvm_config.use_default_substitutions()
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'))

View File

@ -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:'

View File

@ -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]

View File

@ -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.

View File

@ -1,8 +0,0 @@
# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
# FIXME: remove this file when we flip the default for --allow-unused-prefixes.
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]

View File

@ -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'))

View File

@ -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.

View File

@ -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(