[PATCH] D98691: [FileCheck] Fix PR49531: invalid use of string var

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 18 01:39:04 PDT 2021


jhenderson added inline comments.


================
Comment at: llvm/lib/FileCheck/FileCheck.cpp:460
   StringRef Name = Str.take_front(I);
   Str = Str.substr(I);
   return VariableProperties {Name, IsPseudo};
----------------
thopre wrote:
> jhenderson wrote:
> > I wonder if it would make more sense to add the check to this function, somewhere around here. This is the "parseVariable" function after all, so seems like the logical place to reject invalid variable names, rather than the place it is currently detected. What do you think?
> A trailer has to be allowed when parsing a variable use because it could be `[[@LINE+1]]`. If the variable is a pseudo variable, parsing is deferred to the numeric substitution block parsing. Otherwise any trailer is an error. Perhaps it's time to remove all uses of `[[@LINE]]` in favor of `[[#@LINE]]`
This function already knows whether it is a pseudo variable, so doesn't that mean you can do something like `if(!IsPseudo) /*error if trailer*/`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98691



More information about the llvm-commits mailing list