diff options
author | Thomas Preud'homme <thomasp@graphcore.ai> | 2020-06-11 16:14:24 +0100 |
---|---|---|
committer | Thomas Preud'homme <thomasp@graphcore.ai> | 2021-03-12 18:14:17 +0000 |
commit | f9e2a62cc594c96194908a3ac4804caa07f86ba6 (patch) | |
tree | 4b8cc4ded5871af4f417cd94e3f74d620dbb9cdc /llvm/lib/FileCheck/FileCheckImpl.h | |
parent | 4affd0c40eccbce921f185e1e09f84f8194cd4cf (diff) | |
download | llvm-f9e2a62cc594c96194908a3ac4804caa07f86ba6.zip llvm-f9e2a62cc594c96194908a3ac4804caa07f86ba6.tar.gz llvm-f9e2a62cc594c96194908a3ac4804caa07f86ba6.tar.bz2 |
[FileCheck] Add support for hex alternate form in FileCheck
Add printf-style alternate form flag to prefix hex number with 0x when
present. This works on both empty numeric expression (e.g. variable
definition from input) and when matching a numeric expression. The
syntax is as follows:
[[#%#<precision specifier><format specifier>, ...]
where <precision specifier> and <format specifier> are optional and ...
can be a variable definition or not with an empty expression or not.
This feature was requested in https://reviews.llvm.org/D81144#2075532
for llvm/test/MC/ELF/gen-dwarf64.s
Reviewed By: jdenny
Differential Revision: https://reviews.llvm.org/D97845
Diffstat (limited to 'llvm/lib/FileCheck/FileCheckImpl.h')
-rw-r--r-- | llvm/lib/FileCheck/FileCheckImpl.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h index 05b2a52..1966b0e 100644 --- a/llvm/lib/FileCheck/FileCheckImpl.h +++ b/llvm/lib/FileCheck/FileCheckImpl.h @@ -54,6 +54,8 @@ struct ExpressionFormat { private: Kind Value; unsigned Precision = 0; + /// printf-like "alternate form" selected. + bool AlternateForm = false; public: /// Evaluates a format to true if it can be used in a match. @@ -63,7 +65,7 @@ public: /// their kinds and precision are the same. bool operator==(const ExpressionFormat &Other) const { return Value != Kind::NoFormat && Value == Other.Value && - Precision == Other.Precision; + Precision == Other.Precision && AlternateForm == Other.AlternateForm; } bool operator!=(const ExpressionFormat &Other) const { @@ -81,6 +83,8 @@ public: explicit ExpressionFormat(Kind Value) : Value(Value), Precision(0){}; explicit ExpressionFormat(Kind Value, unsigned Precision) : Value(Value), Precision(Precision){}; + explicit ExpressionFormat(Kind Value, unsigned Precision, bool AlternateForm) + : Value(Value), Precision(Precision), AlternateForm(AlternateForm){}; /// \returns a wildcard regular expression string that matches any value in /// the format represented by this instance and no other value, or an error |