Skip to content

Commit 81cd230

Browse files
committed
Handle all enum values in switch/case
1 parent d6eae52 commit 81cd230

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+518
-177
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ bool java_bytecode_languaget::typecheck(
825825
}
826826
}
827827
break;
828-
default:
828+
case LAZY_METHODS_MODE_EXTERNAL_DRIVER:
829829
// Our caller is in charge of elaborating methods on demand.
830830
break;
831831
}

jbmc/src/miniz/miniz.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7105,8 +7105,9 @@ const char *mz_zip_get_error_string(mz_zip_error mz_err)
71057105
return "validation failed";
71067106
case MZ_ZIP_WRITE_CALLBACK_FAILED:
71077107
return "write calledback failed";
7108-
default:
7109-
break;
7108+
case MZ_ZIP_TOTAL_ERRORS:
7109+
// not an actual error, just the maximum index
7110+
break;
71107111
}
71117112

71127113
return "unknown error";

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,21 @@ void custom_bitvector_domaint::transform(
536536
}
537537
break;
538538

539-
default:
540-
{
541-
}
539+
case CATCH:
540+
case THROW:
541+
case RETURN:
542+
case ATOMIC_BEGIN:
543+
case ATOMIC_END:
544+
case END_FUNCTION:
545+
case LOCATION:
546+
case START_THREAD:
547+
case END_THREAD:
548+
case SKIP:
549+
case ASSERT:
550+
case ASSUME:
551+
case INCOMPLETE_GOTO:
552+
case NO_INSTRUCTION_TYPE:
553+
break;
542554
}
543555
}
544556

src/analyses/escape_analysis.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,22 @@ void escape_domaint::transform(
253253
// This is the edge to the call site.
254254
break;
255255

256-
default:
257-
{
258-
}
256+
case GOTO:
257+
case CATCH:
258+
case THROW:
259+
case RETURN:
260+
case ATOMIC_BEGIN:
261+
case ATOMIC_END:
262+
case LOCATION:
263+
case START_THREAD:
264+
case END_THREAD:
265+
case ASSERT:
266+
case ASSUME:
267+
case SKIP:
268+
case OTHER:
269+
case INCOMPLETE_GOTO:
270+
case NO_INSTRUCTION_TYPE:
271+
break;
259272
}
260273
}
261274

@@ -444,9 +457,7 @@ void escape_analysist::instrument(
444457

445458
const goto_programt::instructiont &instruction=*i_it;
446459

447-
switch(instruction.type)
448-
{
449-
case ASSIGN:
460+
if(instruction.type == ASSIGN)
450461
{
451462
const code_assignt &code_assign=to_code_assign(instruction.code);
452463

@@ -460,9 +471,7 @@ void escape_analysist::instrument(
460471
false,
461472
ns);
462473
}
463-
break;
464-
465-
case DEAD:
474+
else if(instruction.type == DEAD)
466475
{
467476
const code_deadt &code_dead=to_code_dead(instruction.code);
468477

@@ -512,12 +521,6 @@ void escape_analysist::instrument(
512521
i_it++;
513522
}
514523
}
515-
break;
516-
517-
default:
518-
{
519-
}
520-
}
521524
}
522525

523526
Forall_goto_program_instructions(i_it, f_it->second.body)

src/analyses/global_may_alias.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,24 @@ void global_may_alias_domaint::transform(
129129
}
130130
break;
131131

132-
default:
133-
{
134-
}
132+
case FUNCTION_CALL:
133+
case GOTO:
134+
case CATCH:
135+
case THROW:
136+
case RETURN:
137+
case ATOMIC_BEGIN:
138+
case ATOMIC_END:
139+
case LOCATION:
140+
case START_THREAD:
141+
case END_THREAD:
142+
case ASSERT:
143+
case ASSUME:
144+
case SKIP:
145+
case END_FUNCTION:
146+
case OTHER:
147+
case INCOMPLETE_GOTO:
148+
case NO_INSTRUCTION_TYPE:
149+
break;
135150
}
136151
}
137152

src/analyses/interval_domain.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,21 @@ void interval_domaint::transform(
108108
}
109109
break;
110110

111-
default:
112-
{
113-
}
111+
case CATCH:
112+
case THROW:
113+
case RETURN:
114+
case ATOMIC_BEGIN:
115+
case ATOMIC_END:
116+
case END_FUNCTION:
117+
case START_THREAD:
118+
case END_THREAD:
119+
case ASSERT:
120+
case LOCATION:
121+
case SKIP:
122+
case OTHER:
123+
case INCOMPLETE_GOTO:
124+
case NO_INSTRUCTION_TYPE:
125+
break;
114126
}
115127
}
116128

src/analyses/invariant_set_domain.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,18 @@ void invariant_set_domaint::transform(
7575
invariant_set.make_threaded();
7676
break;
7777

78-
default:
79-
{
80-
// do nothing
81-
}
78+
case CATCH:
79+
case THROW:
80+
case DEAD:
81+
case ATOMIC_BEGIN:
82+
case ATOMIC_END:
83+
case END_FUNCTION:
84+
case LOCATION:
85+
case END_THREAD:
86+
case SKIP:
87+
case INCOMPLETE_GOTO:
88+
case NO_INSTRUCTION_TYPE:
89+
// do nothing
90+
break;
8291
}
8392
}

src/analyses/local_bitvector_analysis.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,23 @@ void local_bitvector_analysist::build()
308308
}
309309
break;
310310

311-
default:
312-
{
313-
}
311+
case CATCH:
312+
case THROW:
313+
case RETURN:
314+
case ATOMIC_BEGIN:
315+
case ATOMIC_END:
316+
case LOCATION:
317+
case START_THREAD:
318+
case END_THREAD:
319+
case SKIP:
320+
case OTHER:
321+
case ASSERT:
322+
case ASSUME:
323+
case GOTO:
324+
case END_FUNCTION:
325+
case INCOMPLETE_GOTO:
326+
case NO_INSTRUCTION_TYPE:
327+
break;
314328
}
315329

316330
for(const auto &succ : node.successors)

src/analyses/local_cfg.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,23 @@ void local_cfgt::build(const goto_programt &goto_program)
7373
case END_THREAD:
7474
break; // no successor
7575

76-
default:
76+
case CATCH:
77+
case RETURN:
78+
case ATOMIC_BEGIN:
79+
case ATOMIC_END:
80+
case LOCATION:
81+
case SKIP:
82+
case OTHER:
83+
case ASSERT:
84+
case ASSUME:
85+
case FUNCTION_CALL:
86+
case DECL:
87+
case DEAD:
88+
case ASSIGN:
89+
case INCOMPLETE_GOTO:
90+
case NO_INSTRUCTION_TYPE:
7791
node.successors.push_back(loc_nr+1);
92+
break;
7893
}
7994
}
8095
}

src/analyses/local_may_alias.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,23 @@ void local_may_aliast::build(const goto_functiont &goto_function)
419419
}
420420
break;
421421

422-
default:
423-
{
424-
}
422+
case CATCH:
423+
case THROW:
424+
case RETURN:
425+
case GOTO:
426+
case START_THREAD:
427+
case END_THREAD:
428+
case ATOMIC_BEGIN:
429+
case ATOMIC_END:
430+
case LOCATION:
431+
case SKIP:
432+
case END_FUNCTION:
433+
case OTHER:
434+
case ASSERT:
435+
case ASSUME:
436+
case INCOMPLETE_GOTO:
437+
case NO_INSTRUCTION_TYPE:
438+
break;
425439
}
426440

427441
for(local_cfgt::successorst::const_iterator

src/analyses/local_safe_pointers.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ void local_safe_pointerst::operator()(const goto_programt &goto_program)
119119
case RETURN:
120120
case THROW:
121121
case CATCH:
122+
case END_FUNCTION:
123+
case ATOMIC_BEGIN:
124+
case ATOMIC_END:
122125
break;
123126

124127
// Possible checks:
@@ -163,7 +166,13 @@ void local_safe_pointerst::operator()(const goto_programt &goto_program)
163166

164167
break;
165168

166-
default:
169+
case ASSIGN:
170+
case START_THREAD:
171+
case END_THREAD:
172+
case FUNCTION_CALL:
173+
case OTHER:
174+
case INCOMPLETE_GOTO:
175+
case NO_INSTRUCTION_TYPE:
167176
// Pessimistically assume all other instructions might overwrite any
168177
// pointer with a possibly-null value.
169178
checked_expressions.clear();

src/analyses/uncaught_exceptions_analysis.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,24 @@ void uncaught_exceptions_domaint::transform(
125125
join(uea.exceptions_map[function_name]);
126126
break;
127127
}
128-
default:
129-
{}
128+
case DECL:
129+
case DEAD:
130+
case ASSIGN:
131+
case RETURN:
132+
case GOTO:
133+
case ATOMIC_BEGIN:
134+
case ATOMIC_END:
135+
case START_THREAD:
136+
case END_THREAD:
137+
case END_FUNCTION:
138+
case ASSERT:
139+
case ASSUME:
140+
case LOCATION:
141+
case SKIP:
142+
case OTHER:
143+
case INCOMPLETE_GOTO:
144+
case NO_INSTRUCTION_TYPE:
145+
break;
130146
}
131147
}
132148

src/analyses/uninitialized_domain.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ void uninitialized_domaint::transform(
2929
if(has_values.is_false())
3030
return;
3131

32-
switch(from->type)
33-
{
34-
case DECL:
32+
if(from->is_decl())
3533
{
3634
const irep_idt &identifier=
3735
to_code_decl(from->code).get_identifier();
@@ -40,9 +38,7 @@ void uninitialized_domaint::transform(
4038
if(!symbol.is_static_lifetime)
4139
uninitialized.insert(identifier);
4240
}
43-
break;
44-
45-
default:
41+
else
4642
{
4743
std::list<exprt> read=expressions_read(*from);
4844
std::list<exprt> written=expressions_written(*from);
@@ -54,7 +50,6 @@ void uninitialized_domaint::transform(
5450
for(const auto &expr : read)
5551
assign(expr);
5652
}
57-
}
5853
}
5954

6055
void uninitialized_domaint::assign(const exprt &lhs)

src/ansi-c/c_typecast.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,13 @@ void c_typecastt::implicit_typecast_arithmetic(
417417
case RATIONAL: new_type=rational_typet(); break;
418418
case REAL: new_type=real_typet(); break;
419419
case INTEGER: new_type=integer_typet(); break;
420-
case COMPLEX: return; // do nothing
421-
default: return;
420+
case COMPLEX:
421+
case OTHER:
422+
case VOIDPTR:
423+
case FIXEDBV:
424+
case LARGE_UNSIGNED_INT:
425+
case LARGE_SIGNED_INT:
426+
return; // do nothing
422427
}
423428

424429
if(new_type != expr.type())

src/cpp/cpp_id.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ std::ostream &operator<<(std::ostream &out, const cpp_idt::id_classt &id_class)
111111
case cpp_idt::id_classt::BLOCK_SCOPE: return out<<"BLOCK_SCOPE";
112112
case cpp_idt::id_classt::TEMPLATE_SCOPE: return out<<"TEMPLATE_SCOPE";
113113
case cpp_idt::id_classt::NAMESPACE: return out<<"NAMESPACE";
114-
default: return out << "(OTHER)";
114+
case cpp_idt::id_classt::ENUM: return out<<"ENUM";
115115
}
116116

117117
UNREACHABLE;

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,9 +1680,8 @@ exprt cpp_typecheck_resolvet::resolve(
16801680
}
16811681
break;
16821682

1683-
default:
1684-
{
1685-
}
1683+
case wantt::BOTH:
1684+
break;
16861685
}
16871686

16881687
return result;

src/cpp/parse.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,8 @@ bool Parser::rTemplateDecl(cpp_declarationt &decl)
10441044
decl.swap(body);
10451045
break;
10461046

1047-
default:
1047+
case num_tdks:
1048+
case tdk_unknown:
10481049
UNREACHABLE;
10491050
break;
10501051
}

0 commit comments

Comments
 (0)