[llvm] [FileCheck] Fix --enable-var-scope for numvars after reassignment (PR #157158)
Thomas Preud'homme via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 9 06:17:39 PDT 2025
================
@@ -1218,6 +1218,8 @@ Pattern::MatchResult Pattern::match(StringRef Buffer,
StringRef MatchedValue = MatchInfo[CaptureParenGroup];
ExpressionFormat Format = DefinedNumericVariable->getImplicitFormat();
APInt Value = Format.valueFromStringRepr(MatchedValue, SM);
+ Context->GlobalNumericVariableTable.try_emplace(NumericVariableDef.getKey(),
----------------
RoboTux wrote:
I think this can be solved more easily by simply not removing the variable from the numeric table in the first place. We already clear the variable value and that is what ensure --enable-var-scope works. Numeric variable use are not resolved by looking in the GlobalNumericVariableTable but by looking into a numeric variable structure which is shared between a def and a use. So clearing that variable is enough and any redefinition define a separate numeric variable. The clearValue() call is what prevents a use from reading something already defined.
https://github.com/llvm/llvm-project/pull/157158
More information about the llvm-commits
mailing list