[PATCH] D81667: [RFC, FileCheck] Add precision to format specifier

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 03:40:35 PDT 2020


thopre added inline comments.


================
Comment at: llvm/lib/Support/FileCheck.cpp:86
   }
 }
 
----------------
grimar wrote:
> Perhaps, it might be simpler just to merge switches and write the logic here as:
> 
> 
> ```
> Expected<std::string> ExpressionFormat::getWildcardRegex() const {
>   if (Value == Kind::NoFormat)
>     return createStringError(std::errc::invalid_argument,
>                              "trying to match value with invalid format");
>   switch (Value) {
>   case Kind::Unsigned:
>     if (Precision)
>       return ("-?([1-9][0-9]*)?[0-9]{" + Twine(Precision) + "}").str();
>     return std::string("[0-9]+");
>   case Kind::Signed:
>      ...
>   default:
>     llvm_unreachable("....");
>   }
> }
> ```
I'm not a big fan of repeating the formatting logic for the Precision case so I've kept that bit as is. What do you think of the result?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81667



More information about the llvm-commits mailing list