Files
clang-p2996/llvm/test/FileCheck/numeric-defines.txt
Thomas Preud'homme 4cd9b853b5 FileCheck [8/12]: Define numeric var from expr
Summary:
This patch is part of a patch series to add support for FileCheck
numeric expressions. This specific patch lift the restriction for a
numeric expression to either be a variable definition or a numeric
expression to try to match.

This commit allows a numeric variable to be set to the result of the
evaluation of a numeric expression after it has been matched
successfully. When it happens, the variable is allowed to be used on
the same line since its value is known at match time.

It also makes use of this possibility to reuse the parsing code to
parse a command-line definition by crafting a mirror string of the
-D option with the equal sign replaced by a colon sign, e.g. for option
'-D#NUMVAL=10' it creates the string
'-D#NUMVAL=10 (parsed as [[#NUMVAL:10]])' where the numeric expression
is parsed to define NUMVAL. This result in a few tests needing updating
for the location diagnostics on top of the tests for the new feature.

It also enables empty numeric expression which match any number without
defining a variable. This is done here rather than in commit #5 of the
patch series because it requires to dissociate automatic regex insertion
in RegExStr from variable definition which would make commit #5 even
bigger than it already is.

Copyright:
    - Linaro (changes up to diff 183612 of revision D55940)
    - GraphCore (changes in later versions of revision D55940 and
                 in new revision created off D55940)

Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk

Subscribers: hiraditya, llvm-commits, probinson, dblaikie, grimar, arichardson, tra, rnk, kristina, hfinkel, rogfer01, JonChesterfield

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D60388

> llvm-svn: 366860

llvm-svn: 366897
2019-07-24 12:38:22 +00:00

39 lines
2.2 KiB
Plaintext

; Test functionality of -D# option: numeric variables are defined to the right
; value and CHECK directives using them match as expected given the value set.
RUN: FileCheck -D#NUMVAL1=8 -D#NUMVAL2='NUMVAL1 + 4' -check-prefixes CHECKNUM1,CHECKNUM2 -input-file %s %s
RUN: not FileCheck -D#NUMVAL1=7 -D#NUMVAL2=12 -check-prefix CHECKNUM1 -input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace -check-prefix NUMERRMSG1
RUN: not FileCheck -D#NUMVAL1=8 -D#NUMVAL2=8 -check-prefix CHECKNUM2 -input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace -check-prefix NUMERRMSG2
RUN: not FileCheck -D#NUMVAL1=8 -D#NUMVAL2=8 -check-prefix NUMNOT -input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace -check-prefixes NOT-NUMERRMSG1
RUN: not FileCheck -D#NUMVAL1=7 -D#NUMVAL2=12 -check-prefix NUMNOT -input-file %s %s 2>&1 \
RUN: | FileCheck %s --strict-whitespace -check-prefixes NOT-NUMERRMSG2
RUN: FileCheck -D#NUMVAL1=7 -D#NUMVAL2=8 -check-prefixes NUMNOT -input-file %s %s
Numeric value #1 = 8
Numeric value #2 = 12
CHECKNUM1: Numeric value #1 = [[#NUMVAL1]]
CHECKNUM2: Numeric value #2 = [[#NUMVAL2]]
NUMNOT-NOT: Numeric value #1 = [[#NUMVAL1]]
NUMNOT-NOT: Numeric value #2 = [[#NUMVAL2]]
NUMERRMSG1: defines.txt:[[#@LINE-5]]:12: error: CHECKNUM1: expected string not found in input
NUMERRMSG1: defines.txt:1:1: note: scanning from here
NUMERRMSG1: defines.txt:1:1: note: with "NUMVAL1" equal to "7"
NUMERRMSG1: defines.txt:[[#@LINE-10]]:1: note: possible intended match here
NUMERRMSG2: defines.txt:[[#@LINE-9]]:12: error: CHECKNUM2: expected string not found in input
NUMERRMSG2: defines.txt:1:1: note: scanning from here
NUMERRMSG2: defines.txt:1:1: note: with "NUMVAL2" equal to "8"
NUMERRMSG2: defines.txt:[[#@LINE-14]]:1: note: possible intended match here
NOT-NUMERRMSG1: defines.txt:[[#@LINE-13]]:13: error: {{NUMNOT}}-NOT: excluded string found in input
NOT-NUMERRMSG1: defines.txt:[[#@LINE-18]]:1: note: found here
NOT-NUMERRMSG1: defines.txt:[[#@LINE-19]]:1: note: with "NUMVAL1" equal to "8"
NOT-NUMERRMSG2: defines.txt:[[#@LINE-16]]:13: error: {{NUMNOT}}-NOT: excluded string found in input
NOT-NUMERRMSG2: defines.txt:[[#@LINE-21]]:1: note: found here
NOT-NUMERRMSG2: defines.txt:[[#@LINE-22]]:1: note: with "NUMVAL2" equal to "12"