[PATCH] D22403: FileCheck Enhancement - pattern templates.

Elena Lepilkina via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 23:55:04 PDT 2016


eklepilkina added a comment.

In https://reviews.llvm.org/D22403#491468, @aprantl wrote:

> They are also both placeholders for a pattern. Can you give an example where it is useful to tell the difference between a use of a pattern and a use of a plain old variable? Does it make the test more readable?
>  I'm not saying that we have to share the syntax, but adding more syntax increases the cognitive load on testcase authors and we should make sure we are doing it for the right reasons.


Firstly, variables should be defined in some check-line. So we can't create variables separately. In case of patterns you can create a lot of frequently used patterns once (for example in separate file and then include this file where you need (see patch https://reviews.llvm.org/D22500)). Moreover pattern can have their own variables.

> I didn't yet understand how pattern variables are supposed to work: Is \:(variable)\=(value) supposed to be an argument to a pattern use that immediately precedes it? Or is it modifying global state similar to regular variable definition in FileCheck?


Variables are arguments. I don't understand what the global state do you mean.

> If the latter is the case, why does it come after the pattern in the example? In the former case, wouldn't it be better to have syntax that looks more like passing in an argument?


Do you mean something like \#pattern(a, b)? Or what? There is no order of variables during defining it. One variable can be used in pattern several times in different places. I just need variable name to find place in pattern and its value.

> In the documentation the example showed a pattern use on its own, here it appears inside of a regexp. To make sure I understand the proposal correctly :-)


Yes, I have a mistake in documentation. Now pattern  can be used only in regular expressions. But if we change syntax to use [[  ]], I'll can add possible use of them in fixed strings in line-checks.

> it might help if you could add your new syntax to the grammar I posted earlier.


Syntax as is now.

  ACTION <- CHECK-DEFINE-PATTERN IDENT ':' MATCH '\n' ;
  ACTION <- CHECK-DEFINE-PATTERN IDENT ':' REGEX_DEF '\n' ;
  PATTERN_VAR <-;
  PATTERN_VAR <-' \:('IDENT')';
  REGEX_VARS <- POSIX_REGEX;
  REGEX_VARS <- REGEX_VARS PATTERN_VAR REGEX_VARS;
  REGEX_DEF <- '{{' REGEX_VARS '}}';
  VAR_VALUE <-;
  VAR_VALUE <- '\:('IDENT')\=('TEXT')' VAR_VALUE;
  PATTERN_USE <- POSIX_REGEX;
  PATTERN_USE <- POSIX_REGEX '\#('IDENT')'VAR_VALUE PATTERN_USE;
  REGEX <- '{{' PATTERN_USE '}}';


https://reviews.llvm.org/D22403





More information about the llvm-commits mailing list