[PATCH] D60386: FileCheck [6/12]: Introduce numeric variable definition

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 06:56:17 PST 2020


thopre marked 2 inline comments as done.
thopre added inline comments.


================
Comment at: llvm/trunk/docs/CommandGuide/FileCheck.rst:630-632
+Important note: In its current implementation, a numeric expression cannot use
+a numeric variable defined on the same line.
+
----------------
hliao wrote:
> Just curious why we have such a restriction. Could someone elaborate more?
> 
> That makes numeric checks on the same line must be written in split like this
> 
> CHECK: [[#VAR:...]]
> CHECK-SAME: [[#VAR + 1]]
> 
> instead of
> 
> CHECK: [[#VAR:...]] [[#VAR + 1]]
> 
> That's quite verbose.
This is not currently done for 2 reasons:

  # The first reason is that the current code assumes the value of numeric expression is known at match time but in the case [[#VAR:]] [[#VAR+1]] the value VAR+1 is not known since VAR is not known yet. I have a patch planned to address that later in the patch series [1]
  # The more serious problem is how to deal with input such as 10 12 13 and the CHECK [[#VAR:]] {{.*}} [[#VAR+1]] check. Here you'd want the CHECK to be successful and VAR to be assigned the value 12. However FileCheck with the aforementioned patch will ask the regex engine to match the input against the regex "([0-9]+) ([0-9]+)" and will then check the captured text to verify that the numeric expression is verified. However that regex will capture 10 and 12, being the first 2 numbers. Now given the .* how to look at all other possible matches? We would need help from the regex engine but the API only gives us a match/no match answer with captured text.

[1] https://reviews.llvm.org/D60392 which needs serious rebasing

Hope this answers your question.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60386/new/

https://reviews.llvm.org/D60386





More information about the llvm-commits mailing list