jingham created this revision. jingham added a reviewer: JDevlieghere. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
I forgot to add a "return true" to the new OptionValueFileColonLine::Clear method which the Windows compiler caught (thanks Jonas for fixing that!) But that made me wonder if returning true was actually doing any good. How could clearing an OptionValue fail? And what would you do about it. The answer was "nothing" since all the implementations returned true, and none of the clients checked the return value. This is just unsetting some ivars, so it should always succeed and clients shouldn't have to worry about that happening. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D84253 Files: lldb/include/lldb/Interpreter/OptionValue.h lldb/include/lldb/Interpreter/OptionValueArch.h lldb/include/lldb/Interpreter/OptionValueArray.h lldb/include/lldb/Interpreter/OptionValueBoolean.h lldb/include/lldb/Interpreter/OptionValueChar.h lldb/include/lldb/Interpreter/OptionValueDictionary.h lldb/include/lldb/Interpreter/OptionValueEnumeration.h lldb/include/lldb/Interpreter/OptionValueFileColonLine.h lldb/include/lldb/Interpreter/OptionValueFileSpec.h lldb/include/lldb/Interpreter/OptionValueFileSpecList.h lldb/include/lldb/Interpreter/OptionValueFormat.h lldb/include/lldb/Interpreter/OptionValueFormatEntity.h lldb/include/lldb/Interpreter/OptionValueLanguage.h lldb/include/lldb/Interpreter/OptionValuePathMappings.h lldb/include/lldb/Interpreter/OptionValueProperties.h lldb/include/lldb/Interpreter/OptionValueRegex.h lldb/include/lldb/Interpreter/OptionValueSInt64.h lldb/include/lldb/Interpreter/OptionValueString.h lldb/include/lldb/Interpreter/OptionValueUInt64.h lldb/include/lldb/Interpreter/OptionValueUUID.h lldb/source/Interpreter/OptionValueFormatEntity.cpp lldb/source/Interpreter/OptionValueProperties.cpp
Index: lldb/source/Interpreter/OptionValueProperties.cpp =================================================================== --- lldb/source/Interpreter/OptionValueProperties.cpp +++ lldb/source/Interpreter/OptionValueProperties.cpp @@ -517,11 +517,10 @@ return false; } -bool OptionValueProperties::Clear() { +void OptionValueProperties::Clear() { const size_t num_properties = m_properties.size(); for (size_t i = 0; i < num_properties; ++i) m_properties[i].GetValue()->Clear(); - return true; } Status OptionValueProperties::SetValueFromString(llvm::StringRef value, Index: lldb/source/Interpreter/OptionValueFormatEntity.cpp =================================================================== --- lldb/source/Interpreter/OptionValueFormatEntity.cpp +++ lldb/source/Interpreter/OptionValueFormatEntity.cpp @@ -29,11 +29,10 @@ } } -bool OptionValueFormatEntity::Clear() { +void OptionValueFormatEntity::Clear() { m_current_entry = m_default_entry; m_current_format = m_default_format; m_value_was_set = false; - return true; } static void EscapeBackticks(llvm::StringRef str, std::string &dst) { Index: lldb/include/lldb/Interpreter/OptionValueUUID.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueUUID.h +++ lldb/include/lldb/Interpreter/OptionValueUUID.h @@ -36,10 +36,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_uuid.Clear(); m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueUInt64.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueUInt64.h +++ lldb/include/lldb/Interpreter/OptionValueUInt64.h @@ -47,10 +47,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueString.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueString.h +++ lldb/include/lldb/Interpreter/OptionValueString.h @@ -85,10 +85,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueSInt64.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueSInt64.h +++ lldb/include/lldb/Interpreter/OptionValueSInt64.h @@ -50,10 +50,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueRegex.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueRegex.h +++ lldb/include/lldb/Interpreter/OptionValueRegex.h @@ -36,10 +36,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_regex = RegularExpression(m_default_regex_str); m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueProperties.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueProperties.h +++ lldb/include/lldb/Interpreter/OptionValueProperties.h @@ -34,7 +34,7 @@ Type GetType() const override { return eTypeProperties; } - bool Clear() override; + void Clear() override; lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValuePathMappings.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValuePathMappings.h +++ lldb/include/lldb/Interpreter/OptionValuePathMappings.h @@ -35,10 +35,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_path_mappings.Clear(m_notify_changes); m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueLanguage.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueLanguage.h +++ lldb/include/lldb/Interpreter/OptionValueLanguage.h @@ -41,10 +41,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueFormatEntity.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueFormatEntity.h +++ lldb/include/lldb/Interpreter/OptionValueFormatEntity.h @@ -34,7 +34,7 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override; + void Clear() override; lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueFormat.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueFormat.h +++ lldb/include/lldb/Interpreter/OptionValueFormat.h @@ -38,10 +38,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueFileSpecList.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueFileSpecList.h +++ lldb/include/lldb/Interpreter/OptionValueFileSpecList.h @@ -39,11 +39,10 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { std::lock_guard<std::recursive_mutex> lock(m_mutex); m_current_value.Clear(); m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueFileSpec.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueFileSpec.h +++ lldb/include/lldb/Interpreter/OptionValueFileSpec.h @@ -41,12 +41,11 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() 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<>(); - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueFileColonLine.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueFileColonLine.h +++ lldb/include/lldb/Interpreter/OptionValueFileColonLine.h @@ -35,7 +35,7 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_file_spec.Clear(); m_line_number = LLDB_INVALID_LINE_NUMBER; m_column_number = LLDB_INVALID_COLUMN_NUMBER; Index: lldb/include/lldb/Interpreter/OptionValueEnumeration.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueEnumeration.h +++ lldb/include/lldb/Interpreter/OptionValueEnumeration.h @@ -47,10 +47,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueDictionary.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueDictionary.h +++ lldb/include/lldb/Interpreter/OptionValueDictionary.h @@ -35,10 +35,9 @@ SetValueFromString(llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign) override; - bool Clear() override { + void Clear() override { m_values.clear(); m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueChar.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueChar.h +++ lldb/include/lldb/Interpreter/OptionValueChar.h @@ -38,10 +38,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } // Subclass specific functions Index: lldb/include/lldb/Interpreter/OptionValueBoolean.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueBoolean.h +++ lldb/include/lldb/Interpreter/OptionValueBoolean.h @@ -37,10 +37,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } void AutoComplete(CommandInterpreter &interpreter, Index: lldb/include/lldb/Interpreter/OptionValueArray.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueArray.h +++ lldb/include/lldb/Interpreter/OptionValueArray.h @@ -36,10 +36,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_values.clear(); m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValueArch.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValueArch.h +++ lldb/include/lldb/Interpreter/OptionValueArch.h @@ -47,10 +47,9 @@ SetValueFromString(const char *, VarSetOperationType = eVarSetOperationAssign) = delete; - bool Clear() override { + void Clear() override { m_current_value = m_default_value; m_value_was_set = false; - return true; } lldb::OptionValueSP DeepCopy() const override; Index: lldb/include/lldb/Interpreter/OptionValue.h =================================================================== --- lldb/include/lldb/Interpreter/OptionValue.h +++ lldb/include/lldb/Interpreter/OptionValue.h @@ -85,7 +85,7 @@ SetValueFromString(llvm::StringRef value, VarSetOperationType op = eVarSetOperationAssign); - virtual bool Clear() = 0; + virtual void Clear() = 0; virtual lldb::OptionValueSP DeepCopy() const = 0;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits