[PATCH] D97845: [FileCheck] Add support for hex alternate form in FileCheck

Thomas Preud'homme via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 02:00:18 PST 2021


thopre added inline comments.


================
Comment at: llvm/lib/FileCheck/FileCheck.cpp:118
     unsigned LeadingZeros = Precision - AbsoluteValueStr.size();
-    return (Twine(SignPrefix) + std::string(LeadingZeros, '0') +
-            AbsoluteValueStr)
+    return (Twine(AlternateFormPrefix) + Twine(SignPrefix) +
+            std::string(LeadingZeros, '0') + AbsoluteValueStr)
----------------
jdenny wrote:
> AlternateFormPrefix and SignPrefix are reversed relative to the version without leading zeroes below.  Can it actually matter for hex?  Regardless, it should probably be consistent.
It does not matter because the 0x prefix is only for hex format but I agree better to be consistent.


================
Comment at: llvm/lib/FileCheck/FileCheckImpl.h:57
   unsigned Precision = 0;
+  bool AlternateForm = false;
 
----------------
jdenny wrote:
> Can we have a more exact name than `AlternateForm`?  Maybe `HexPrefix`.  If generality is better, then maybe `TypePrefix`.
That is taken from printf's manual:



>        The character % is followed by zero or more of the following flags:
> 
>        #      The value should be converted to an "alternate form".

For now it only applies to hex values but if we ever support one of the other format e.g. float format) then it would make sense to make it generic. I could rename it for now, we'll need to remember to rename it if a floating-point format gets supported at some point



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97845



More information about the llvm-commits mailing list