@@ -325,8 +325,6 @@ main_function_resultt get_main_symbol(
325325 message_handlert &message_handler,
326326 bool allow_no_body)
327327{
328- main_function_resultt res;
329-
330328 messaget message (message_handler);
331329
332330 // find main symbol
@@ -341,10 +339,9 @@ main_function_resultt get_main_symbol(
341339
342340 if (main_symbol_id==irep_idt ())
343341 {
344- message.error () << " main symbol resolution failed: "
345- << error_message << messaget::eom;
346- res.status =main_function_resultt::Error;
347- return res;
342+ message.error ()
343+ << " main symbol resolution failed: " << error_message << messaget::eom;
344+ return main_function_resultt::Error;
348345 }
349346
350347 symbol_tablet::opt_const_symbol_reft symbol=
@@ -356,17 +353,12 @@ main_function_resultt get_main_symbol(
356353 // check if it has a body
357354 if (symbol->get ().value .is_nil () && !allow_no_body)
358355 {
359- message.error () << " main method `" << main_class
360- << " ' has no body" << messaget::eom;
361- res.main_function =*symbol;
362- res.status =main_function_resultt::Error;
363- return res;
356+ message.error ()
357+ << " main method `" << main_class << " ' has no body" << messaget::eom;
358+ return main_function_resultt::Error;
364359 }
365360
366- // Return found function
367- res.main_function =*symbol;
368- res.status =main_function_resultt::Success;
369- return res;
361+ return main_function_resultt (*symbol); // Return found function
370362 }
371363 else
372364 {
@@ -375,43 +367,34 @@ main_function_resultt get_main_symbol(
375367
376368 // are we given a main class?
377369 if (main_class.empty ())
378- {
379- res.status =main_function_resultt::NotFound;
380- return res; // silently ignore
381- }
370+ return main_function_resultt::NotFound; // silently ignore
382371
383- std::string entry_method=
384- id2string (main_class)+" .main" ;
372+ std::string entry_method=id2string (main_class)+" .main" ;
385373
386374 std::string prefix=" java::" +entry_method+" :" ;
387375
388376 // look it up
389377 std::set<const symbolt *> matches;
390378
391- for (symbol_tablet::symbolst::const_iterator
392- s_it=symbol_table.symbols .begin ();
393- s_it!=symbol_table.symbols .end ();
394- s_it++)
379+ for (const auto &named_symbol : symbol_table.symbols )
395380 {
396- if (s_it->second .type .id ()==ID_code &&
397- has_prefix (id2string (s_it->first ), prefix))
398- matches.insert (&s_it->second );
381+ if (named_symbol.second .type .id ()==ID_code
382+ && has_prefix (id2string (named_symbol.first ), prefix))
383+ {
384+ matches.insert (&named_symbol.second );
385+ }
399386 }
400387
401388 if (matches.empty ())
402- {
403389 // Not found, silently ignore
404- res.status =main_function_resultt::NotFound;
405- return res;
406- }
390+ return main_function_resultt::NotFound;
407391
408392 if (matches.size ()>1 )
409393 {
410- message.error () << " main method in `" << main_class
411- << " ' is ambiguous" << messaget::eom;
412- res.main_function =symbolt ();
413- res.status =main_function_resultt::Error;
414- return res; // give up with error, no main
394+ message.error ()
395+ << " main method in `" << main_class
396+ << " ' is ambiguous" << messaget::eom;
397+ return main_function_resultt::Error; // give up with error, no main
415398 }
416399
417400 // function symbol
@@ -420,17 +403,12 @@ main_function_resultt get_main_symbol(
420403 // check if it has a body
421404 if (symbol.value .is_nil () && !allow_no_body)
422405 {
423- message.error () << " main method `" << main_class
424- << " ' has no body" << messaget::eom;
425- res.main_function =symbol;
426- res.status =main_function_resultt::Error;
427- return res; // give up with error
406+ message.error ()
407+ << " main method `" << main_class << " ' has no body" << messaget::eom;
408+ return main_function_resultt::Error; // give up with error
428409 }
429410
430- // Return found function
431- res.main_function =symbol;
432- res.status =main_function_resultt::Success;
433- return res;
411+ return symbol; // Return found function
434412 }
435413}
436414
0 commit comments