Skip to content

Commit f451d27

Browse files
authored
[lldb] Assert on invalid default {S,U}Int64 (NFC) (#126590)
Both the default value and the min/max value are within LLDB's control, so an assert is more appropriate than a runtime check.
1 parent fb623a3 commit f451d27

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

lldb/include/lldb/Interpreter/OptionValueSInt64.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ class OptionValueSInt64 : public Cloneable<OptionValueSInt64, OptionValue> {
6868
}
6969

7070
bool SetDefaultValue(int64_t value) {
71-
if (value >= m_min_value && value <= m_max_value) {
72-
m_default_value = value;
73-
return true;
74-
}
75-
return false;
71+
assert(value >= m_min_value && value <= m_max_value &&
72+
"disallowed default value");
73+
m_default_value = value;
74+
return true;
7675
}
7776

7877
void SetMinimumValue(int64_t v) { m_min_value = v; }

lldb/include/lldb/Interpreter/OptionValueUInt64.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,17 @@ class OptionValueUInt64 : public Cloneable<OptionValueUInt64, OptionValue> {
7373
}
7474

7575
bool SetDefaultValue(uint64_t value) {
76-
if (value >= m_min_value && value <= m_max_value) {
77-
m_default_value = value;
78-
return true;
79-
}
80-
return false;
76+
assert(value >= m_min_value && value <= m_max_value &&
77+
"disallowed default value");
78+
m_default_value = value;
79+
return true;
8180
}
8281

83-
void SetMinimumValue(int64_t v) { m_min_value = v; }
82+
void SetMinimumValue(uint64_t v) { m_min_value = v; }
8483

8584
uint64_t GetMinimumValue() const { return m_min_value; }
8685

87-
void SetMaximumValue(int64_t v) { m_max_value = v; }
86+
void SetMaximumValue(uint64_t v) { m_max_value = v; }
8887

8988
uint64_t GetMaximumValue() const { return m_max_value; }
9089

0 commit comments

Comments
 (0)