Skip to content

Commit 7e72ce3

Browse files
committed
Adding one more unit test and marking a few variables as 'const'.
1 parent d501431 commit 7e72ce3

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lldb/tools/lldb-dap/Handler/VariablesRequestHandler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ VariablesRequestHandler::Run(const VariablesArguments &arguments) const {
123123
if (!variable.IsValid())
124124
break;
125125

126-
int64_t frame_var_ref =
126+
const int64_t frame_var_ref =
127127
dap.variables.InsertVariable(variable, /*is_permanent=*/false);
128128
variables.emplace_back(CreateVariable(
129129
variable, frame_var_ref, hex,
@@ -136,7 +136,8 @@ VariablesRequestHandler::Run(const VariablesArguments &arguments) const {
136136
// children.
137137
lldb::SBValue variable = dap.variables.GetVariable(var_ref);
138138
if (variable.IsValid()) {
139-
bool is_permanent = dap.variables.IsPermanentVariableReference(var_ref);
139+
const bool is_permanent =
140+
dap.variables.IsPermanentVariableReference(var_ref);
140141
auto addChild = [&](lldb::SBValue child,
141142
std::optional<std::string> custom_name = {}) {
142143
if (!child.IsValid())
@@ -150,7 +151,7 @@ VariablesRequestHandler::Run(const VariablesArguments &arguments) const {
150151
/*is_name_duplicated=*/false, custom_name));
151152
};
152153
const int64_t num_children = variable.GetNumChildren();
153-
int64_t end_idx = start + ((count == 0) ? num_children : count);
154+
const int64_t end_idx = start + ((count == 0) ? num_children : count);
154155
int64_t i = start;
155156
for (; i < end_idx && i < num_children; ++i)
156157
addChild(variable.GetChildAtIndex(i));

lldb/unittests/DAP/JSONUtilsTest.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,15 @@ TEST(JSONUtilsTest, DecodeMemoryReference) {
206206
/*required=*/false));
207207
}
208208

209+
{
210+
addr_t addr = LLDB_INVALID_ADDRESS;
211+
json::Path::Root root;
212+
EXPECT_FALSE(DecodeMemoryReference(json::Value{"string"}, "mem_ref", addr,
213+
root,
214+
/*required=*/true));
215+
EXPECT_THAT_ERROR(root.getError(), FailedWithMessage("expected object"));
216+
}
217+
209218
{
210219
addr_t addr = LLDB_INVALID_ADDRESS;
211220
json::Path::Root root;

0 commit comments

Comments
 (0)