@@ -211,7 +211,6 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
211
211
target->EvaluateExpression (s, exe_ctx->GetFramePtr (), valobj_sp, options);
212
212
213
213
bool success = false ;
214
- bool error_set = false ;
215
214
if (expr_result == eExpressionCompleted) {
216
215
if (valobj_sp)
217
216
valobj_sp = valobj_sp->GetQualifiedRepresentationIfAvailable (
@@ -224,48 +223,39 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s,
224
223
error_ptr->Clear ();
225
224
return addr;
226
225
}
227
- if (error_ptr) {
228
- error_set = true ;
226
+ if (error_ptr)
229
227
error_ptr->SetErrorStringWithFormat (
230
228
" address expression \" %s\" resulted in a value whose type "
231
229
" can't be converted to an address: %s" ,
232
230
s.str ().c_str (), valobj_sp->GetTypeName ().GetCString ());
233
- }
234
- } else {
235
- // Since the compiler can't handle things like "main + 12" we should try to
236
- // do this for now. The compiler doesn't like adding offsets to function
237
- // pointer types.
238
- static RegularExpression g_symbol_plus_offset_regex (
239
- " ^(.*)([-\\ +])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$" );
240
-
241
- llvm::SmallVector<llvm::StringRef, 4 > matches;
242
- if (g_symbol_plus_offset_regex.Execute (sref, &matches)) {
243
- uint64_t offset = 0 ;
244
- llvm::StringRef name = matches[1 ];
245
- llvm::StringRef sign = matches[2 ];
246
- llvm::StringRef str_offset = matches[3 ];
247
- if (!str_offset.getAsInteger (0 , offset)) {
248
- Status error;
249
- addr = ToAddress (exe_ctx, name, LLDB_INVALID_ADDRESS, &error);
250
- if (addr != LLDB_INVALID_ADDRESS) {
251
- if (sign[0 ] == ' +' )
252
- return addr + offset;
253
- return addr - offset;
254
- }
255
- }
256
- }
231
+ return {};
232
+ }
257
233
258
- if (error_ptr) {
259
- error_set = true ;
260
- error_ptr->SetErrorStringWithFormat (
261
- " address expression \" %s\" evaluation failed" , s.str ().c_str ());
234
+ // Since the compiler can't handle things like "main + 12" we should try to
235
+ // do this for now. The compiler doesn't like adding offsets to function
236
+ // pointer types.
237
+ static RegularExpression g_symbol_plus_offset_regex (
238
+ " ^(.*)([-\\ +])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$" );
239
+
240
+ llvm::SmallVector<llvm::StringRef, 4 > matches;
241
+ if (g_symbol_plus_offset_regex.Execute (sref, &matches)) {
242
+ uint64_t offset = 0 ;
243
+ llvm::StringRef name = matches[1 ];
244
+ llvm::StringRef sign = matches[2 ];
245
+ llvm::StringRef str_offset = matches[3 ];
246
+ if (!str_offset.getAsInteger (0 , offset)) {
247
+ Status error;
248
+ addr = ToAddress (exe_ctx, name, LLDB_INVALID_ADDRESS, &error);
249
+ if (addr != LLDB_INVALID_ADDRESS) {
250
+ if (sign[0 ] == ' +' )
251
+ return addr + offset;
252
+ return addr - offset;
253
+ }
262
254
}
263
255
}
264
256
265
- if (error_ptr) {
266
- if (!error_set)
267
- error_ptr->SetErrorStringWithFormat (" invalid address expression \" %s\" " ,
268
- s.str ().c_str ());
269
- }
257
+ if (error_ptr)
258
+ error_ptr->SetErrorStringWithFormat (
259
+ " address expression \" %s\" evaluation failed" , s.str ().c_str ());
270
260
return {};
271
261
}
0 commit comments