Skip to content

Commit 3e98a28

Browse files
[lldb][NFC] Remove else after return in OptionArgParse
This will enable us to prove that there is unreachable code in this function in a subsequent commit.
1 parent 7a86cc6 commit 3e98a28

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

lldb/source/Interpreter/OptionArgParser.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ lldb::addr_t OptionArgParser::ToAddress(const ExecutionContext *exe_ctx,
168168
std::optional<lldb::addr_t>
169169
OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
170170
Status *error_ptr) {
171-
bool error_set = false;
172171
if (s.empty()) {
173172
if (error_ptr)
174173
error_ptr->SetErrorStringWithFormat("invalid address expression \"%s\"",
@@ -212,6 +211,7 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
212211
target->EvaluateExpression(s, exe_ctx->GetFramePtr(), valobj_sp, options);
213212

214213
bool success = false;
214+
bool error_set = false;
215215
if (expr_result == eExpressionCompleted) {
216216
if (valobj_sp)
217217
valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable(
@@ -223,16 +223,14 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
223223
if (error_ptr)
224224
error_ptr->Clear();
225225
return addr;
226-
} else {
227-
if (error_ptr) {
228-
error_set = true;
229-
error_ptr->SetErrorStringWithFormat(
230-
"address expression \"%s\" resulted in a value whose type "
231-
"can't be converted to an address: %s",
232-
s.str().c_str(), valobj_sp->GetTypeName().GetCString());
233-
}
234226
}
235-
227+
if (error_ptr) {
228+
error_set = true;
229+
error_ptr->SetErrorStringWithFormat(
230+
"address expression \"%s\" resulted in a value whose type "
231+
"can't be converted to an address: %s",
232+
s.str().c_str(), valobj_sp->GetTypeName().GetCString());
233+
}
236234
} else {
237235
// Since the compiler can't handle things like "main + 12" we should try to
238236
// do this for now. The compiler doesn't like adding offsets to function
@@ -252,8 +250,7 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
252250
if (addr != LLDB_INVALID_ADDRESS) {
253251
if (sign[0] == '+')
254252
return addr + offset;
255-
else
256-
return addr - offset;
253+
return addr - offset;
257254
}
258255
}
259256
}

0 commit comments

Comments
 (0)