aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
-rw-r--r--llvm/lib/FileCheck/FileCheck.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp
index ce35a5b..9245db4 100644
--- a/llvm/lib/FileCheck/FileCheck.cpp
+++ b/llvm/lib/FileCheck/FileCheck.cpp
@@ -1218,6 +1218,14 @@ Pattern::MatchResult Pattern::match(StringRef Buffer,
StringRef MatchedValue = MatchInfo[CaptureParenGroup];
ExpressionFormat Format = DefinedNumericVariable->getImplicitFormat();
APInt Value = Format.valueFromStringRepr(MatchedValue, SM);
+ // Numeric variables are already inserted into GlobalNumericVariableTable
+ // during parsing, but clearLocalVars might remove them, so we must
+ // reinsert them. Numeric-variable resolution does not access
+ // GlobalNumericVariableTable; it directly uses a pointer to the variable.
+ // However, other functions (such as clearLocalVars) may require active
+ // variables to be in the table.
+ Context->GlobalNumericVariableTable.try_emplace(NumericVariableDef.getKey(),
+ DefinedNumericVariable);
DefinedNumericVariable->setValue(Value, MatchedValue);
}