@@ -53,36 +53,26 @@ void ClangPersistentVariables::RemovePersistentVariable(
53
53
54
54
RemoveVariable (variable);
55
55
56
- const char *name = variable->GetName ().AsCString ();
56
+ // Check if the removed variable was the last one that was created. If yes,
57
+ // reuse the variable id for the next variable.
57
58
58
- if (*name != ' $' )
59
+ // Nothing to do if we have not assigned a variable id so far.
60
+ if (m_next_persistent_variable_id == 0 )
59
61
return ;
60
- name++;
61
-
62
- bool is_error = false ;
63
-
64
- if (variable->GetCompilerType ().GetTypeSystem ()->SupportsLanguage (
65
- lldb::eLanguageTypeSwift)) {
66
- switch (*name) {
67
- case ' R' :
68
- break ;
69
- case ' E' :
70
- is_error = true ;
71
- break ;
72
- default :
73
- return ;
74
- }
75
- name++;
76
- }
77
62
78
- uint32_t value = strtoul (name, nullptr , 0 );
79
- if (is_error) {
80
- if (value == m_next_persistent_error_id - 1 )
81
- m_next_persistent_error_id--;
82
- } else {
83
- if (value == m_next_persistent_variable_id - 1 )
84
- m_next_persistent_variable_id--;
85
- }
63
+ llvm::StringRef name = variable->GetName ().GetStringRef ();
64
+ // Remove the prefix from the variable that only the indes is left.
65
+ if (!name.consume_front (GetPersistentVariablePrefix (false )))
66
+ return ;
67
+
68
+ // Check if the variable contained a variable id.
69
+ uint32_t variable_id;
70
+ if (name.getAsInteger (10 , variable_id))
71
+ return ;
72
+ // If it's the most recent variable id that was assigned, make sure that this
73
+ // variable id will be used for the next persistent variable.
74
+ if (variable_id == m_next_persistent_variable_id - 1 )
75
+ m_next_persistent_variable_id--;
86
76
}
87
77
88
78
std::optional<CompilerType>
0 commit comments