Skip to content

Commit d1adb0b

Browse files
Complete ToJSON for OptionValues (#137375)
Completes the ToJSON function for `OptionValue` types and make the interface function pure virtual --------- Co-authored-by: Jonas Devlieghere <[email protected]>
1 parent e9a34e4 commit d1adb0b

34 files changed

+61
-37
lines changed

lldb/include/lldb/Interpreter/OptionValue.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,7 @@ class OptionValue {
9393
virtual void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
9494
uint32_t dump_mask) = 0;
9595

96-
// TODO: make this function pure virtual after implementing it in all
97-
// child classes.
98-
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) {
99-
// Return nullptr which will create a llvm::json::Value() that is a NULL
100-
// value. No setting should ever really have a NULL value in JSON. This
101-
// indicates an error occurred and if/when we add a FromJSON() it will know
102-
// to fail if someone tries to set it with a NULL JSON value.
103-
return nullptr;
104-
}
96+
virtual llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const = 0;
10597

10698
virtual Status
10799
SetValueFromString(llvm::StringRef value,

lldb/include/lldb/Interpreter/OptionValueArch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class OptionValueArch : public Cloneable<OptionValueArch, OptionValue> {
3838
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3939
uint32_t dump_mask) override;
4040

41+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override;
42+
4143
Status
4244
SetValueFromString(llvm::StringRef value,
4345
VarSetOperationType op = eVarSetOperationAssign) override;

lldb/include/lldb/Interpreter/OptionValueArray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OptionValueArray : public Cloneable<OptionValueArray, OptionValue> {
2929
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3030
uint32_t dump_mask) override;
3131

32-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
32+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override;
3333

3434
Status
3535
SetValueFromString(llvm::StringRef value,

lldb/include/lldb/Interpreter/OptionValueBoolean.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OptionValueBoolean : public Cloneable<OptionValueBoolean, OptionValue> {
2929
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3030
uint32_t dump_mask) override;
3131

32-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
32+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
3333
return m_current_value;
3434
}
3535

lldb/include/lldb/Interpreter/OptionValueChar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class OptionValueChar : public Cloneable<OptionValueChar, OptionValue> {
3030
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3131
uint32_t dump_mask) override;
3232

33-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
33+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
3434
return m_current_value;
3535
}
3636

lldb/include/lldb/Interpreter/OptionValueDictionary.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class OptionValueDictionary
3434
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3535
uint32_t dump_mask) override;
3636

37-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
37+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override;
3838

3939
Status
4040
SetValueFromString(llvm::StringRef value,

lldb/include/lldb/Interpreter/OptionValueEnumeration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class OptionValueEnumeration
4141
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
4242
uint32_t dump_mask) override;
4343

44-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
44+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override;
4545

4646
Status
4747
SetValueFromString(llvm::StringRef value,

lldb/include/lldb/Interpreter/OptionValueFileColonLine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class OptionValueFileColonLine :
2929
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3030
uint32_t dump_mask) override;
3131

32+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override;
33+
3234
Status
3335
SetValueFromString(llvm::StringRef value,
3436
VarSetOperationType op = eVarSetOperationAssign) override;

lldb/include/lldb/Interpreter/OptionValueFileSpec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class OptionValueFileSpec : public Cloneable<OptionValueFileSpec, OptionValue> {
3535
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3636
uint32_t dump_mask) override;
3737

38-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override {
38+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override {
3939
return m_current_value.GetPath();
4040
}
4141

lldb/include/lldb/Interpreter/OptionValueFileSpecList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class OptionValueFileSpecList
3333
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
3434
uint32_t dump_mask) override;
3535

36-
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) override;
36+
llvm::json::Value ToJSON(const ExecutionContext *exe_ctx) const override;
3737

3838
Status
3939
SetValueFromString(llvm::StringRef value,

0 commit comments

Comments
 (0)