aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheckImpl.h
diff options
context:
space:
mode:
authorThomas Preud'homme <thomas.preudhomme@arm.com>2023-06-28 22:53:56 +0100
committerThomas Preud'homme <thomas.preudhomme@arm.com>2023-07-04 21:39:20 +0100
commitcf57fcfa0256df8d69638ab1462267413755ba86 (patch)
tree137a0de503c101dd35caf296a7c5c9d519168e01 /llvm/lib/FileCheck/FileCheckImpl.h
parent1746ac42cae1dbe5fdef2af8e887a7e6015605ec (diff)
downloadllvm-cf57fcfa0256df8d69638ab1462267413755ba86.zip
llvm-cf57fcfa0256df8d69638ab1462267413755ba86.tar.gz
llvm-cf57fcfa0256df8d69638ab1462267413755ba86.tar.bz2
[FileCheck, 1/4] NFC: Switch ExpressionValue to APInt
Use APInt internally to store values represented by ExpressionValue. This will allow to support any integer values in FileCheck numeric expression in a subsequent commit. Reviewed By: arichardson Differential Revision: https://reviews.llvm.org/D154428
Diffstat (limited to 'llvm/lib/FileCheck/FileCheckImpl.h')
-rw-r--r--llvm/lib/FileCheck/FileCheckImpl.h14
1 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/FileCheck/FileCheckImpl.h b/llvm/lib/FileCheck/FileCheckImpl.h
index 3a3f4ec..b67b70e 100644
--- a/llvm/lib/FileCheck/FileCheckImpl.h
+++ b/llvm/lib/FileCheck/FileCheckImpl.h
@@ -15,6 +15,7 @@
#ifndef LLVM_LIB_FILECHECK_FILECHECKIMPL_H
#define LLVM_LIB_FILECHECK_FILECHECKIMPL_H
+#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/FileCheck/FileCheck.h"
@@ -120,15 +121,15 @@ public:
/// Class representing a numeric value.
class ExpressionValue {
private:
- uint64_t Value;
- bool Negative;
+ APInt Value;
public:
+ // Store signed and unsigned 64-bit integers in a signed 65-bit APInt.
template <class T>
- explicit ExpressionValue(T Val) : Value(Val), Negative(Val < 0) {}
+ explicit ExpressionValue(T Val) : Value(65, Val, /*isSigned=*/Val < 0) {}
bool operator==(const ExpressionValue &Other) const {
- return Value == Other.Value && isNegative() == Other.isNegative();
+ return Value == Other.Value;
}
bool operator!=(const ExpressionValue &Other) const {
@@ -136,10 +137,7 @@ public:
}
/// Returns true if value is signed and negative, false otherwise.
- bool isNegative() const {
- assert((Value != 0 || !Negative) && "Unexpected negative zero!");
- return Negative;
- }
+ bool isNegative() const { return Value.isNegative(); }
/// \returns the value as a signed integer or an error if the value is out of
/// range.