For instance, breakpoints run an expression when evaluating a condition. If each of these expression evaluations incremented the result numbering, you could end up running an expression, and getting:
(lldb) expression foo
$1 = ...
Then do a continue, and then:
(lldb) expression foo
$14532 =
That would be disconcerting...
There was code (but no test, alas) to make this work, but when we refactored the PersistentExpression class, this got broken.
This patch goes back to using the original method of computing the number. But I also changed the API's a bit. When you went to get a result variable name in the current method you had to do:
auto prefix = persistent_expression_state->GetPersistentVariablePrefix(); ConstString persistent_variable_name = persistent_expression_state->GetNextPersistentVariableName(target, prefix);
The persistent variable prefix is only ever used to make the persistent variable name, so having this be done in two steps is unnecessary. It was also odd that you needed the target - that was only because we the "next result variable index" had been errantly moved into the target. So I made GetNextPersistentVariableName the public interface, and passed in only the is_error bool. I left the GetPersistentVariablePrefix in as a protected method - it doesn't do anything for C, but it is used for swift.
I also added a test.