diff options
| author | Nicolas Vasilache <ntv@google.com> | 2018-08-27 10:26:15 -0700 |
|---|---|---|
| committer | jpienaar <jpienaar@google.com> | 2019-03-29 13:06:36 -0700 |
| commit | a124e9c4a548dc00671abcabc7467ad95b9b5c3e (patch) | |
| tree | 7c50ab6d472c5b7852d1f28f53686f26c685a14a /mlir/lib/Parser/Token.cpp | |
| parent | 6cc9786c3e47a6531c52e947d2c4d26315102810 (diff) | |
| download | bcm5719-llvm-a124e9c4a548dc00671abcabc7467ad95b9b5c3e.tar.gz bcm5719-llvm-a124e9c4a548dc00671abcabc7467ad95b9b5c3e.zip | |
Avoid hardcoded 4096 constant
This commit creates a static constexpr limit for the IntegerType
bitwidth and uses it. The check had to be moved because Token is
not aware of IR/Type and it was a sign the abstraction leaked:
bitwidth limit is not a property of the Token but of the IntegerType.
Added a positive and a negative test at the limit.
PiperOrigin-RevId: 210388192
Diffstat (limited to 'mlir/lib/Parser/Token.cpp')
| -rw-r--r-- | mlir/lib/Parser/Token.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/mlir/lib/Parser/Token.cpp b/mlir/lib/Parser/Token.cpp index 4c3f9e4258e..4e01f5a6a53 100644 --- a/mlir/lib/Parser/Token.cpp +++ b/mlir/lib/Parser/Token.cpp @@ -72,9 +72,7 @@ Optional<double> Token::getFloatingPointValue() const { Optional<unsigned> Token::getIntTypeBitwidth() const { unsigned result = 0; if (spelling[1] == '0' || - spelling.drop_front().getAsInteger(10, result) || - // Arbitrary but large limit on bitwidth. - result > 4096 || result == 0) + spelling.drop_front().getAsInteger(10, result) || result == 0) return None; return result; } |

