aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/FileCheck.cpp
diff options
context:
space:
mode:
authorThomas Preud'homme <thomasp@graphcore.ai>2019-07-05 21:49:59 +0000
committerThomas Preud'homme <thomasp@graphcore.ai>2019-07-05 21:49:59 +0000
commit096600a4b073dd94a366cc8e57bff93c34ff6966 (patch)
tree011fae1ff68447fea83017db7af4d7ca3e052681 /llvm/lib/Support/FileCheck.cpp
parentcf45cb0b9d48fcfe15c0a5f5388095614c30268a (diff)
downloadllvm-096600a4b073dd94a366cc8e57bff93c34ff6966.zip
llvm-096600a4b073dd94a366cc8e57bff93c34ff6966.tar.gz
llvm-096600a4b073dd94a366cc8e57bff93c34ff6966.tar.bz2
[FileCheck] Simplify numeric variable interface
Summary: This patch simplifies 2 aspects in the FileCheckNumericVariable code. First, setValue() method is turned into a void function since being called only on undefined variable is an invariant and is now asserted rather than returned. This remove the assert from the callers. Second, clearValue() method is also turned into a void function since the only caller does not check its return value since it may be trying to clear the value of variable that is already cleared without this being noteworthy. Reviewers: jhenderson, chandlerc, jdenny, probinson, grimar, arichardson, rnk Subscribers: JonChesterfield, rogfer01, hfinkel, kristina, rnk, tra, arichardson, grimar, dblaikie, probinson, llvm-commits, hiraditya Tags: #llvm Differential Revision: https://reviews.llvm.org/D64231 llvm-svn: 365249
Diffstat (limited to 'llvm/lib/Support/FileCheck.cpp')
-rw-r--r--llvm/lib/Support/FileCheck.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/Support/FileCheck.cpp b/llvm/lib/Support/FileCheck.cpp
index 03e892af..12431d9 100644
--- a/llvm/lib/Support/FileCheck.cpp
+++ b/llvm/lib/Support/FileCheck.cpp
@@ -24,18 +24,15 @@
using namespace llvm;
-bool FileCheckNumericVariable::setValue(uint64_t NewValue) {
- if (Value)
- return true;
+void FileCheckNumericVariable::setValue(uint64_t NewValue) {
+ assert(!Value && "Overwriting numeric variable's value is not allowed");
Value = NewValue;
- return false;
}
-bool FileCheckNumericVariable::clearValue() {
+void FileCheckNumericVariable::clearValue() {
if (!Value)
- return true;
+ return;
Value = None;
- return false;
}
Expected<uint64_t> FileCheckExpression::eval() const {
@@ -623,8 +620,7 @@ Expected<size_t> FileCheckPattern::match(StringRef Buffer, size_t &MatchLen,
if (MatchedValue.getAsInteger(10, Val))
return FileCheckErrorDiagnostic::get(SM, MatchedValue,
"Unable to represent numeric value");
- if (DefinedNumericVariable->setValue(Val))
- llvm_unreachable("Numeric variable redefined");
+ DefinedNumericVariable->setValue(Val);
}
// Like CHECK-NEXT, CHECK-EMPTY's match range is considered to start after