https://github.com/da-viper created 
https://github.com/llvm/llvm-project/pull/208471

The clear function guarded by the internal mutex.
This happens when we have to threads one trying to set a value and the other 
reseting the value.

The derived classes are forced to implement the `ClearImpl`. and base 
`OptionValue` hold the mutex and calls `ClearImpl` on clear. 

>From 03b70402114c3ed8b3b7d62c0fca7b522aca1144 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <[email protected]>
Date: Thu, 9 Jul 2026 15:03:29 +0100
Subject: [PATCH] [lldb-dap] Avoid data race when clearing an OptionValue

The clear function guarded by the internal mutex.
This happens when we have to threads one trying to set a value and the
other reseting the value.
---
 lldb/include/lldb/Interpreter/OptionValue.h        |  6 +++++-
 lldb/include/lldb/Interpreter/OptionValueArch.h    | 10 +++++-----
 lldb/include/lldb/Interpreter/OptionValueArray.h   | 10 +++++-----
 lldb/include/lldb/Interpreter/OptionValueBoolean.h | 10 +++++-----
 lldb/include/lldb/Interpreter/OptionValueChar.h    | 10 +++++-----
 .../lldb/Interpreter/OptionValueDictionary.h       |  9 +++++----
 .../lldb/Interpreter/OptionValueEnumeration.h      | 10 +++++-----
 .../lldb/Interpreter/OptionValueFileColonLine.h    | 12 ++++++------
 .../include/lldb/Interpreter/OptionValueFileSpec.h | 14 +++++++-------
 .../lldb/Interpreter/OptionValueFileSpecList.h     | 11 ++++++-----
 lldb/include/lldb/Interpreter/OptionValueFormat.h  | 10 +++++-----
 .../lldb/Interpreter/OptionValueFormatEntity.h     |  3 ++-
 .../include/lldb/Interpreter/OptionValueLanguage.h | 10 +++++-----
 .../lldb/Interpreter/OptionValuePathMappings.h     | 10 +++++-----
 .../lldb/Interpreter/OptionValueProperties.h       |  4 ++--
 lldb/include/lldb/Interpreter/OptionValueRegex.h   |  9 +++++----
 lldb/include/lldb/Interpreter/OptionValueSInt64.h  | 10 +++++-----
 lldb/include/lldb/Interpreter/OptionValueString.h  | 10 +++++-----
 lldb/include/lldb/Interpreter/OptionValueUInt64.h  | 10 +++++-----
 lldb/include/lldb/Interpreter/OptionValueUUID.h    | 10 +++++-----
 lldb/source/Interpreter/OptionValueBoolean.cpp     |  4 ++--
 .../source/Interpreter/OptionValueFormatEntity.cpp |  2 +-
 lldb/source/Interpreter/OptionValueProperties.cpp  |  2 +-
 23 files changed, 102 insertions(+), 94 deletions(-)

diff --git a/lldb/include/lldb/Interpreter/OptionValue.h 
b/lldb/include/lldb/Interpreter/OptionValue.h
index 193f2e44aca1b..d41e5bd2e00b2 100644
--- a/lldb/include/lldb/Interpreter/OptionValue.h
+++ b/lldb/include/lldb/Interpreter/OptionValue.h
@@ -102,7 +102,10 @@ class OptionValue {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign);
 
-  virtual void Clear() = 0;
+  virtual void Clear() {
+    std::lock_guard<std::mutex> lock(m_mutex);
+    ClearImpl();
+  }
 
   virtual lldb::OptionValueSP
   DeepCopy(const lldb::OptionValueSP &new_parent) const;
@@ -349,6 +352,7 @@ class OptionValue {
   // Must be overriden by a derived class for correct downcasting the result of
   // DeepCopy to it. Inherit from Cloneable to avoid doing this manually.
   virtual lldb::OptionValueSP Clone() const = 0;
+  virtual void ClearImpl() = 0;
 
   class DefaultValueFormat {
   public:
diff --git a/lldb/include/lldb/Interpreter/OptionValueArch.h 
b/lldb/include/lldb/Interpreter/OptionValueArch.h
index 8b6954f03dd29..db837511bb10b 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArch.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArch.h
@@ -44,11 +44,6 @@ class OptionValueArch : public Cloneable<OptionValueArch, 
OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   void AutoComplete(CommandInterpreter &interpreter,
@@ -71,6 +66,11 @@ class OptionValueArch : public Cloneable<OptionValueArch, 
OptionValue> {
   void SetDefaultValue(const ArchSpec &value) { m_default_value = value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   ArchSpec m_current_value;
   ArchSpec m_default_value;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueArray.h 
b/lldb/include/lldb/Interpreter/OptionValueArray.h
index 34170ef06a188..0bcc9e4388cb7 100644
--- a/lldb/include/lldb/Interpreter/OptionValueArray.h
+++ b/lldb/include/lldb/Interpreter/OptionValueArray.h
@@ -35,11 +35,6 @@ class OptionValueArray : public Cloneable<OptionValueArray, 
OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_values.clear();
-    m_value_was_set = false;
-  }
-
   lldb::OptionValueSP
   DeepCopy(const lldb::OptionValueSP &new_parent) const override;
 
@@ -115,6 +110,11 @@ class OptionValueArray : public 
Cloneable<OptionValueArray, OptionValue> {
   Status SetArgs(const Args &args, VarSetOperationType op);
 
 protected:
+  void ClearImpl() override {
+    m_values.clear();
+    m_value_was_set = false;
+  }
+
   typedef std::vector<lldb::OptionValueSP> collection;
 
   uint32_t m_type_mask;
diff --git a/lldb/include/lldb/Interpreter/OptionValueBoolean.h 
b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
index 72c1ce446b8a0..d2dfe6d5d0654 100644
--- a/lldb/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/lldb/include/lldb/Interpreter/OptionValueBoolean.h
@@ -37,11 +37,6 @@ class OptionValueBoolean : public 
Cloneable<OptionValueBoolean, OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   void AutoComplete(CommandInterpreter &interpreter,
                     CompletionRequest &request) override;
 
@@ -78,6 +73,11 @@ class OptionValueBoolean : public 
Cloneable<OptionValueBoolean, OptionValue> {
   void SetDefaultValue(bool value) { m_default_value = value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   bool m_current_value;
   bool m_default_value;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueChar.h 
b/lldb/include/lldb/Interpreter/OptionValueChar.h
index c1f83a3daf846..d47b1b8a66263 100644
--- a/lldb/include/lldb/Interpreter/OptionValueChar.h
+++ b/lldb/include/lldb/Interpreter/OptionValueChar.h
@@ -38,11 +38,6 @@ class OptionValueChar : public Cloneable<OptionValueChar, 
OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   // Subclass specific functions
@@ -61,6 +56,11 @@ class OptionValueChar : public Cloneable<OptionValueChar, 
OptionValue> {
   void SetDefaultValue(char value) { m_default_value = value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   char m_current_value;
   char m_default_value;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueDictionary.h 
b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
index 800b7fc687640..c4b8bee4407cd 100644
--- a/lldb/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/lldb/include/lldb/Interpreter/OptionValueDictionary.h
@@ -40,10 +40,6 @@ class OptionValueDictionary
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_values.clear();
-    m_value_was_set = false;
-  }
 
   lldb::OptionValueSP
   DeepCopy(const lldb::OptionValueSP &new_parent) const override;
@@ -77,6 +73,11 @@ class OptionValueDictionary
   Status SetArgs(const Args &args, VarSetOperationType op);
 
 protected:
+  void ClearImpl() override {
+    m_values.clear();
+    m_value_was_set = false;
+  }
+
   uint32_t m_type_mask;
   OptionEnumValues m_enum_values;
   llvm::StringMap<lldb::OptionValueSP> m_values;
diff --git a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h 
b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
index e8566934d9fc5..4d71bdd8981b7 100644
--- a/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -47,11 +47,6 @@ class OptionValueEnumeration
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   void AutoComplete(CommandInterpreter &interpreter,
@@ -76,6 +71,11 @@ class OptionValueEnumeration
   void SetEnumerations(const OptionEnumValues &enumerators);
   void DumpEnum(Stream &strm, enum_type value);
 
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   enum_type m_current_value;
   enum_type m_default_value;
   EnumerationMap m_enumerations;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h 
b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
index e2b84f9b81e65..de6984dd6cadf 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileColonLine.h
@@ -35,12 +35,6 @@ class OptionValueFileColonLine :
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_file_spec.Clear();
-    m_line_number = LLDB_INVALID_LINE_NUMBER;
-    m_column_number = LLDB_INVALID_COLUMN_NUMBER;
-  }
-
   void SetFile(const FileSpec &file_spec) { m_file_spec = file_spec; }
   void SetLine(uint32_t line) { m_line_number = line; }
   void SetColumn(uint32_t column) { m_column_number = column; }
@@ -55,6 +49,12 @@ class OptionValueFileColonLine :
   void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
 
 protected:
+  void ClearImpl() override {
+    m_file_spec.Clear();
+    m_line_number = LLDB_INVALID_LINE_NUMBER;
+    m_column_number = LLDB_INVALID_COLUMN_NUMBER;
+  }
+
   FileSpec m_file_spec;
   uint32_t m_line_number = LLDB_INVALID_LINE_NUMBER;
   uint32_t m_column_number = LLDB_INVALID_COLUMN_NUMBER;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h 
b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
index 66f2b2a04ff53..8d29939a53197 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -43,13 +43,6 @@ class OptionValueFileSpec : public 
Cloneable<OptionValueFileSpec, OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-    m_data_sp.reset();
-    m_data_mod_time = llvm::sys::TimePoint<>();
-  }
-
   void AutoComplete(CommandInterpreter &interpreter,
                     CompletionRequest &request) override;
 
@@ -77,6 +70,13 @@ class OptionValueFileSpec : public 
Cloneable<OptionValueFileSpec, OptionValue> {
   void SetCompletionMask(uint32_t mask) { m_completion_mask = mask; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+    m_data_sp.reset();
+    m_data_mod_time = llvm::sys::TimePoint<>();
+  }
+
   FileSpec m_current_value;
   FileSpec m_default_value;
   lldb::DataBufferSP m_data_sp;
diff --git a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h 
b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
index 6250b5ee6fcb2..b2995fa81da3a 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -39,11 +39,6 @@ class OptionValueFileSpecList
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    std::lock_guard<std::recursive_mutex> lock(m_mutex);
-    m_current_value.Clear();
-    m_value_was_set = false;
-  }
 
   bool IsAggregateValue() const override { return true; }
 
@@ -67,6 +62,12 @@ class OptionValueFileSpecList
 protected:
   lldb::OptionValueSP Clone() const override;
 
+  void ClearImpl() override {
+    std::lock_guard<std::recursive_mutex> lock(m_mutex);
+    m_current_value.Clear();
+    m_value_was_set = false;
+  }
+
   mutable std::recursive_mutex m_mutex;
   FileSpecList m_current_value;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormat.h 
b/lldb/include/lldb/Interpreter/OptionValueFormat.h
index 661e8b507d64f..3774eda87c39b 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormat.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormat.h
@@ -37,11 +37,6 @@ class OptionValueFormat
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   // Subclass specific functions
@@ -55,6 +50,11 @@ class OptionValueFormat
   void SetDefaultValue(lldb::Format value) { m_default_value = value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   lldb::Format m_current_value;
   lldb::Format m_default_value;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h 
b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
index bbc1f8c1eec43..665c5f6f6ba65 100644
--- a/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
+++ b/lldb/include/lldb/Interpreter/OptionValueFormatEntity.h
@@ -32,7 +32,6 @@ class OptionValueFormatEntity
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override;
 
   bool IsDefault() const override {
     return m_current_format == m_default_format;
@@ -50,6 +49,8 @@ class OptionValueFormatEntity
   const FormatEntity::Entry &GetDefaultValue() const { return m_default_entry; 
}
 
 protected:
+  void ClearImpl() override;
+
   std::string m_current_format;
   std::string m_default_format;
   FormatEntity::Entry m_current_entry;
diff --git a/lldb/include/lldb/Interpreter/OptionValueLanguage.h 
b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
index 41ddb2a13f15e..237ecda5e5c78 100644
--- a/lldb/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/lldb/include/lldb/Interpreter/OptionValueLanguage.h
@@ -39,11 +39,6 @@ class OptionValueLanguage : public 
Cloneable<OptionValueLanguage, OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   // Subclass specific functions
@@ -57,6 +52,11 @@ class OptionValueLanguage : public 
Cloneable<OptionValueLanguage, OptionValue> {
   void SetDefaultValue(lldb::LanguageType value) { m_default_value = value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   lldb::LanguageType m_current_value;
   lldb::LanguageType m_default_value;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h 
b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
index e0aac2fd44484..e3102a31ffc6b 100644
--- a/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/lldb/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -35,11 +35,6 @@ class OptionValuePathMappings
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_path_mappings.Clear(m_notify_changes);
-    m_value_was_set = false;
-  }
-
   bool IsAggregateValue() const override { return true; }
 
   // Subclass specific functions
@@ -49,6 +44,11 @@ class OptionValuePathMappings
   const PathMappingList &GetCurrentValue() const { return m_path_mappings; }
 
 protected:
+  void ClearImpl() override {
+    m_path_mappings.Clear(m_notify_changes);
+    m_value_was_set = false;
+  }
+
   PathMappingList m_path_mappings;
   bool m_notify_changes;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueProperties.h 
b/lldb/include/lldb/Interpreter/OptionValueProperties.h
index 41c6be67bb990..0735ed25ac47d 100644
--- a/lldb/include/lldb/Interpreter/OptionValueProperties.h
+++ b/lldb/include/lldb/Interpreter/OptionValueProperties.h
@@ -31,8 +31,6 @@ class OptionValueProperties
 
   Type GetType() const override { return eTypeProperties; }
 
-  void Clear() override;
-
   static lldb::OptionValuePropertiesSP
   CreateLocalCopy(const Properties &global_properties);
 
@@ -179,6 +177,8 @@ class OptionValueProperties
     return ((idx < m_properties.size()) ? &m_properties[idx] : nullptr);
   }
 
+  void ClearImpl() override;
+
   bool VerifyPath();
 
   std::string m_name;
diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h 
b/lldb/include/lldb/Interpreter/OptionValueRegex.h
index 2799fea1538dc..92df0025cfc91 100644
--- a/lldb/include/lldb/Interpreter/OptionValueRegex.h
+++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h
@@ -36,10 +36,6 @@ class OptionValueRegex : public Cloneable<OptionValueRegex, 
OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_regex = RegularExpression(m_default_regex_str);
-    m_value_was_set = false;
-  }
 
   bool IsDefault() const override {
     return m_regex.GetText() == m_default_regex_str;
@@ -60,6 +56,11 @@ class OptionValueRegex : public Cloneable<OptionValueRegex, 
OptionValue> {
   bool IsValid() const { return m_regex.IsValid(); }
 
 protected:
+  void ClearImpl() override {
+    m_regex = RegularExpression(m_default_regex_str);
+    m_value_was_set = false;
+  }
+
   RegularExpression m_regex;
   std::string m_default_regex_str;
 };
diff --git a/lldb/include/lldb/Interpreter/OptionValueSInt64.h 
b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
index f19f3f8ab875e..796f9340e18f5 100644
--- a/lldb/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueSInt64.h
@@ -43,11 +43,6 @@ class OptionValueSInt64 : public 
Cloneable<OptionValueSInt64, OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   // Subclass specific functions
@@ -85,6 +80,11 @@ class OptionValueSInt64 : public 
Cloneable<OptionValueSInt64, OptionValue> {
   int64_t GetMaximumValue() const { return m_max_value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   int64_t m_current_value = 0;
   int64_t m_default_value = 0;
   int64_t m_min_value = std::numeric_limits<int64_t>::min();
diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h 
b/lldb/include/lldb/Interpreter/OptionValueString.h
index e199443fa8b49..47bd2a8093406 100644
--- a/lldb/include/lldb/Interpreter/OptionValueString.h
+++ b/lldb/include/lldb/Interpreter/OptionValueString.h
@@ -77,11 +77,6 @@ class OptionValueString : public 
Cloneable<OptionValueString, OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   // Subclass specific functions
@@ -122,6 +117,11 @@ class OptionValueString : public 
Cloneable<OptionValueString, OptionValue> {
   }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   std::string m_current_value;
   std::string m_default_value;
   Flags m_options;
diff --git a/lldb/include/lldb/Interpreter/OptionValueUInt64.h 
b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
index 2a87c19c54bbf..a7bde8b40186e 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUInt64.h
@@ -46,11 +46,6 @@ class OptionValueUInt64 : public 
Cloneable<OptionValueUInt64, OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_current_value = m_default_value;
-    m_value_was_set = false;
-  }
-
   bool IsDefault() const override { return m_current_value == m_default_value; 
}
 
   // Subclass specific functions
@@ -90,6 +85,11 @@ class OptionValueUInt64 : public 
Cloneable<OptionValueUInt64, OptionValue> {
   uint64_t GetMaximumValue() const { return m_max_value; }
 
 protected:
+  void ClearImpl() override {
+    m_current_value = m_default_value;
+    m_value_was_set = false;
+  }
+
   uint64_t m_current_value = 0;
   uint64_t m_default_value = 0;
   uint64_t m_min_value = std::numeric_limits<uint64_t>::min();
diff --git a/lldb/include/lldb/Interpreter/OptionValueUUID.h 
b/lldb/include/lldb/Interpreter/OptionValueUUID.h
index 2b7d9e41bcf77..8de73016352b1 100644
--- a/lldb/include/lldb/Interpreter/OptionValueUUID.h
+++ b/lldb/include/lldb/Interpreter/OptionValueUUID.h
@@ -37,11 +37,6 @@ class OptionValueUUID : public Cloneable<OptionValueUUID, 
OptionValue> {
   SetValueFromString(llvm::StringRef value,
                      VarSetOperationType op = eVarSetOperationAssign) override;
 
-  void Clear() override {
-    m_uuid.Clear();
-    m_value_was_set = false;
-  }
-
   // Subclass specific functions
 
   UUID &GetCurrentValue() { return m_uuid; }
@@ -54,6 +49,11 @@ class OptionValueUUID : public Cloneable<OptionValueUUID, 
OptionValue> {
                     CompletionRequest &request) override;
 
 protected:
+  void ClearImpl() override {
+    m_uuid.Clear();
+    m_value_was_set = false;
+  }
+
   UUID m_uuid;
 };
 
diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp 
b/lldb/source/Interpreter/OptionValueBoolean.cpp
index 023c243b3efc1..fb2e23c7a3128 100644
--- a/lldb/source/Interpreter/OptionValueBoolean.cpp
+++ b/lldb/source/Interpreter/OptionValueBoolean.cpp
@@ -50,8 +50,8 @@ Status OptionValueBoolean::SetValueFromString(llvm::StringRef 
value_str,
     bool success = false;
     bool value = OptionArgParser::ToBoolean(value_str, false, &success);
     if (success) {
-      m_value_was_set = true;
-      m_current_value = value;
+      SetValueAs(value);
+      SetOptionWasSet();
       NotifyValueChanged();
     } else {
       if (value_str.size() == 0)
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp 
b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index b31dd4e475878..63c1f110adabd 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -28,7 +28,7 @@ OptionValueFormatEntity::OptionValueFormatEntity(const char 
*default_format) {
   }
 }
 
-void OptionValueFormatEntity::Clear() {
+void OptionValueFormatEntity::ClearImpl() {
   m_current_entry = m_default_entry;
   m_current_format = m_default_format;
   m_value_was_set = false;
diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp 
b/lldb/source/Interpreter/OptionValueProperties.cpp
index e62c15ec36da3..adea68aa530a6 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -303,7 +303,7 @@ OptionValueString 
*OptionValueProperties::GetPropertyAtIndexAsOptionValueString(
   return nullptr;
 }
 
-void OptionValueProperties::Clear() {
+void OptionValueProperties::ClearImpl() {
   const size_t num_properties = m_properties.size();
   for (size_t i = 0; i < num_properties; ++i)
     m_properties[i].GetValue()->Clear();

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to