summaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-05-14 20:20:03 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2023-05-14 20:30:29 -0700
commitbf76a6e44723b73940ca81c3b17077225b3c4118 (patch)
treef5b7803cdbfcd7b9619e05e450e2886e94685506 /lldb
parent62b5e55512d57b083ac07d40b41242c7116a3d20 (diff)
downloadllvm-bf76a6e44723b73940ca81c3b17077225b3c4118.tar.gz
[lldb] Cleanup OptionValue header and implenentation (NFC)
Group related functions together and remove inconsistencies between them in the implementation.
Diffstat (limited to 'lldb')
-rw-r--r--lldb/include/lldb/Interpreter/OptionValue.h24
-rw-r--r--lldb/source/Interpreter/OptionValue.cpp39
2 files changed, 16 insertions, 47 deletions
diff --git a/lldb/include/lldb/Interpreter/OptionValue.h b/lldb/include/lldb/Interpreter/OptionValue.h
index 9e65c802b370..cd587ed463b1 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 7fa34c55d0f4..2f110d53d958 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -258,8 +258,7 @@ std::optional<bool> 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<char> 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<int64_t> 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<FileSpec> 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<lldb::Format> 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<lldb::LanguageType> 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<int64_t> 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<llvm::StringRef> 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<uint64_t> 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<UUID> 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;
}