[PATCH] D22403: FileCheck Enhancement - pattern templates.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 09:28:55 PDT 2016


aprantl added a comment.

In https://reviews.llvm.org/D22403#489690, @eklepilkina wrote:

> About syntax.
>  There is an idea to do as you advised.
>  Suggested new syntax:
>  [['#template_name]] - use of template 'template_name'. It can occur in CHECK-PATTERN line, when description of one template includes other templates described before. (Without quote, I don't know how escape # here)
>  [[:Variable_name]] - template variable with name 'variable_name'
>  [[:variable_name=value]] - current value of template variable(it's needed when you use template with variables).
>  Is this syntax better? Should I do such way?


Let me start off by saying thanks for working on this!

For reference, here is what I remember the syntax of FileCheck CHECK-lines to be currently:

  ACTION <- CHECK ':' MATCH '\n' ;
  MATCH <- ;
  MATCH <- TEXT MATCH ;
  MATCH <- REGEX MATCH ;
  MATCH <- VAR MATCH ;
  REGEX <- '{{' POSIX_REGEX '}}' ;
  VAR <- '[[' IDENT ':' POSIX_REGEX ']]' ;
  VAR <- '[[' IDENT ']]' ;

Is there a benefit in (or need for) distinguishing between variable uses and pattern uses, or could we piggyback the existing syntax?

As for pattern variables, I really think this review would benefit if we could split out pattern variables into a separate review. 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? 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?


https://reviews.llvm.org/D22403





More information about the llvm-commits mailing list