From: Jonas Devlieghere Date: Mon, 15 May 2023 03:20:03 +0000 (-0700) Subject: [lldb] Cleanup OptionValue header and implenentation (NFC) X-Git-Tag: upstream/17.0.6~8559 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf76a6e44723b73940ca81c3b17077225b3c4118;p=platform%2Fupstream%2Fllvm.git [lldb] Cleanup OptionValue header and implenentation (NFC) Group related functions together and remove inconsistencies between them in the implementation. --- diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h index 9e65c80..cd587ed 100644 --- a/lldb/include/lldb/Interpreter/OptionValue.h +++ b/lldb/include/lldb/Interpreter/OptionValue.h @@ -114,7 +114,8 @@ public: virtual lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx, llvm::StringRef name, Status &error) const { - error.SetErrorStringWithFormat("'%s' is not a value subvalue", name.str().c_str()); + error.SetErrorStringWithFormat("'%s' is not a value subvalue", + name.str().c_str()); return lldb::OptionValueSP(); } @@ -187,79 +188,60 @@ public: Status &error); OptionValueArch *GetAsArch(); - const OptionValueArch *GetAsArch() const; OptionValueArray *GetAsArray(); - const OptionValueArray *GetAsArray() const; OptionValueArgs *GetAsArgs(); - const OptionValueArgs *GetAsArgs() const; OptionValueBoolean *GetAsBoolean(); - - OptionValueChar *GetAsChar(); - const OptionValueBoolean *GetAsBoolean() const; + OptionValueChar *GetAsChar(); const OptionValueChar *GetAsChar() const; OptionValueDictionary *GetAsDictionary(); - const OptionValueDictionary *GetAsDictionary() const; OptionValueEnumeration *GetAsEnumeration(); - const OptionValueEnumeration *GetAsEnumeration() const; OptionValueFileSpec *GetAsFileSpec(); - const OptionValueFileSpec *GetAsFileSpec() const; OptionValueFileSpecList *GetAsFileSpecList(); - const OptionValueFileSpecList *GetAsFileSpecList() const; OptionValueFormat *GetAsFormat(); - const OptionValueFormat *GetAsFormat() const; OptionValueLanguage *GetAsLanguage(); - const OptionValueLanguage *GetAsLanguage() const; OptionValuePathMappings *GetAsPathMappings(); - const OptionValuePathMappings *GetAsPathMappings() const; OptionValueProperties *GetAsProperties(); - const OptionValueProperties *GetAsProperties() const; OptionValueRegex *GetAsRegex(); - const OptionValueRegex *GetAsRegex() const; OptionValueSInt64 *GetAsSInt64(); - const OptionValueSInt64 *GetAsSInt64() const; OptionValueString *GetAsString(); - const OptionValueString *GetAsString() const; OptionValueUInt64 *GetAsUInt64(); - const OptionValueUInt64 *GetAsUInt64() const; OptionValueUUID *GetAsUUID(); - const OptionValueUUID *GetAsUUID() const; OptionValueFormatEntity *GetAsFormatEntity(); - const OptionValueFormatEntity *GetAsFormatEntity() const; bool AppendFileSpecValue(FileSpec file_spec); diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp index 7fa34c5..2f110d5 100644 --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -258,8 +258,7 @@ std::optional OptionValue::GetBooleanValue() const { } bool OptionValue::SetBooleanValue(bool new_value) { - OptionValueBoolean *option_value = GetAsBoolean(); - if (option_value) { + if (OptionValueBoolean *option_value = GetAsBoolean()) { option_value->SetCurrentValue(new_value); return true; } @@ -273,8 +272,7 @@ std::optional OptionValue::GetCharValue() const { } bool OptionValue::SetCharValue(char new_value) { - OptionValueChar *option_value = GetAsChar(); - if (option_value) { + if (OptionValueChar *option_value = GetAsChar()) { option_value->SetCurrentValue(new_value); return true; } @@ -288,8 +286,7 @@ std::optional OptionValue::GetEnumerationValue() const { } bool OptionValue::SetEnumerationValue(int64_t value) { - OptionValueEnumeration *option_value = GetAsEnumeration(); - if (option_value) { + if (OptionValueEnumeration *option_value = GetAsEnumeration()) { option_value->SetCurrentValue(value); return true; } @@ -297,15 +294,13 @@ bool OptionValue::SetEnumerationValue(int64_t value) { } std::optional OptionValue::GetFileSpecValue() const { - const OptionValueFileSpec *option_value = GetAsFileSpec(); - if (option_value) + if (const OptionValueFileSpec *option_value = GetAsFileSpec()) return option_value->GetCurrentValue(); return {}; } bool OptionValue::SetFileSpecValue(FileSpec file_spec) { - OptionValueFileSpec *option_value = GetAsFileSpec(); - if (option_value) { + if (OptionValueFileSpec *option_value = GetAsFileSpec()) { option_value->SetCurrentValue(file_spec, false); return true; } @@ -333,8 +328,7 @@ std::optional OptionValue::GetFormatValue() const { } bool OptionValue::SetFormatValue(lldb::Format new_value) { - OptionValueFormat *option_value = GetAsFormat(); - if (option_value) { + if (OptionValueFormat *option_value = GetAsFormat()) { option_value->SetCurrentValue(new_value); return true; } @@ -348,8 +342,7 @@ std::optional OptionValue::GetLanguageValue() const { } bool OptionValue::SetLanguageValue(lldb::LanguageType new_language) { - OptionValueLanguage *option_value = GetAsLanguage(); - if (option_value) { + if (OptionValueLanguage *option_value = GetAsLanguage()) { option_value->SetCurrentValue(new_language); return true; } @@ -357,15 +350,13 @@ bool OptionValue::SetLanguageValue(lldb::LanguageType new_language) { } const FormatEntity::Entry *OptionValue::GetFormatEntity() const { - const OptionValueFormatEntity *option_value = GetAsFormatEntity(); - if (option_value) + if (const OptionValueFormatEntity *option_value = GetAsFormatEntity()) return &option_value->GetCurrentValue(); return nullptr; } const RegularExpression *OptionValue::GetRegexValue() const { - const OptionValueRegex *option_value = GetAsRegex(); - if (option_value) + if (const OptionValueRegex *option_value = GetAsRegex()) return option_value->GetCurrentValue(); return nullptr; } @@ -377,8 +368,7 @@ std::optional OptionValue::GetSInt64Value() const { } bool OptionValue::SetSInt64Value(int64_t new_value) { - OptionValueSInt64 *option_value = GetAsSInt64(); - if (option_value) { + if (OptionValueSInt64 *option_value = GetAsSInt64()) { option_value->SetCurrentValue(new_value); return true; } @@ -392,8 +382,7 @@ std::optional OptionValue::GetStringValue() const { } bool OptionValue::SetStringValue(llvm::StringRef new_value) { - OptionValueString *option_value = GetAsString(); - if (option_value) { + if (OptionValueString *option_value = GetAsString()) { option_value->SetCurrentValue(new_value); return true; } @@ -407,8 +396,7 @@ std::optional OptionValue::GetUInt64Value() const { } bool OptionValue::SetUInt64Value(uint64_t new_value) { - OptionValueUInt64 *option_value = GetAsUInt64(); - if (option_value) { + if (OptionValueUInt64 *option_value = GetAsUInt64()) { option_value->SetCurrentValue(new_value); return true; } @@ -422,8 +410,7 @@ std::optional OptionValue::GetUUIDValue() const { } bool OptionValue::SetUUIDValue(const UUID &uuid) { - OptionValueUUID *option_value = GetAsUUID(); - if (option_value) { + if (OptionValueUUID *option_value = GetAsUUID()) { option_value->SetCurrentValue(uuid); return true; }