Skip to content

Commit 3616201

Browse files
committedAug 22, 2019
[lldb][NFC] Remove dead code that is supposed to handle invalid command options
Summary: We currently have a bunch of code that is supposed to handle invalid command options, but all this code is unreachable because invalid options are already handled in `Options::Parse`. The only way we can reach this code is when we declare but then not implement an option (which will be made impossible with D65386, which is also when we can completely remove the `default` cases). This patch replaces all this code with `llvm_unreachable` to make clear this is dead code that can't be reached. Reviewers: JDevlieghere Reviewed By: JDevlieghere Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D66522 llvm-svn: 369625
1 parent ae34ed2 commit 3616201

27 files changed

+82
-217
lines changed
 

Diff for: ‎lldb/source/Commands/CommandObjectBreakpoint.cpp

+11-28
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ class lldb_private::BreakpointOptionGroup : public OptionGroup
141141
}
142142
break;
143143
default:
144-
error.SetErrorStringWithFormat("unrecognized option '%c'",
145-
short_option);
146-
break;
144+
llvm_unreachable("Unimplemented option");
147145
}
148146

149147
return error;
@@ -206,9 +204,7 @@ class BreakpointDummyOptionGroup : public OptionGroup
206204
m_use_dummy = true;
207205
break;
208206
default:
209-
error.SetErrorStringWithFormat("unrecognized option '%c'",
210-
short_option);
211-
break;
207+
llvm_unreachable("Unimplemented option");
212208
}
213209

214210
return error;
@@ -486,9 +482,7 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
486482
break;
487483

488484
default:
489-
error.SetErrorStringWithFormat("unrecognized option '%c'",
490-
short_option);
491-
break;
485+
llvm_unreachable("Unimplemented option");
492486
}
493487

494488
return error;
@@ -1208,9 +1202,7 @@ class CommandObjectBreakpointList : public CommandObjectParsed {
12081202
m_internal = true;
12091203
break;
12101204
default:
1211-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1212-
short_option);
1213-
break;
1205+
llvm_unreachable("Unimplemented option");
12141206
}
12151207

12161208
return error;
@@ -1342,9 +1334,7 @@ class CommandObjectBreakpointClear : public CommandObjectParsed {
13421334
break;
13431335

13441336
default:
1345-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1346-
short_option);
1347-
break;
1337+
llvm_unreachable("Unimplemented option");
13481338
}
13491339

13501340
return error;
@@ -1496,9 +1486,7 @@ class CommandObjectBreakpointDelete : public CommandObjectParsed {
14961486
break;
14971487

14981488
default:
1499-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1500-
short_option);
1501-
break;
1489+
llvm_unreachable("Unimplemented option");
15021490
}
15031491

15041492
return error;
@@ -1643,9 +1631,7 @@ class BreakpointNameOptionGroup : public OptionGroup {
16431631
break;
16441632

16451633
default:
1646-
error.SetErrorStringWithFormat("unrecognized short option '%c'",
1647-
short_option);
1648-
break;
1634+
llvm_unreachable("Unimplemented option");
16491635
}
16501636
return error;
16511637
}
@@ -1713,7 +1699,8 @@ class BreakpointAccessOptionGroup : public OptionGroup {
17131699
"invalid boolean value '%s' passed for -L option",
17141700
option_arg.str().c_str());
17151701
} break;
1716-
1702+
default:
1703+
llvm_unreachable("Unimplemented option");
17171704
}
17181705

17191706
return error;
@@ -2175,9 +2162,7 @@ class CommandObjectBreakpointRead : public CommandObjectParsed {
21752162
break;
21762163
}
21772164
default:
2178-
error.SetErrorStringWithFormat("unrecognized option '%c'",
2179-
short_option);
2180-
break;
2165+
llvm_unreachable("Unimplemented option");
21812166
}
21822167

21832168
return error;
@@ -2293,9 +2278,7 @@ class CommandObjectBreakpointWrite : public CommandObjectParsed {
22932278
m_append = true;
22942279
break;
22952280
default:
2296-
error.SetErrorStringWithFormat("unrecognized option '%c'",
2297-
short_option);
2298-
break;
2281+
llvm_unreachable("Unimplemented option");
22992282
}
23002283

23012284
return error;

Diff for: ‎lldb/source/Commands/CommandObjectBreakpointCommand.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ are no syntax errors may indicate that a function was declared but never called.
324324
break;
325325

326326
default:
327-
break;
327+
llvm_unreachable("Unimplemented option");
328328
}
329329
return error;
330330
}
@@ -516,9 +516,7 @@ class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {
516516
break;
517517

518518
default:
519-
error.SetErrorStringWithFormat("unrecognized option '%c'",
520-
short_option);
521-
break;
519+
llvm_unreachable("Unimplemented option");
522520
}
523521

524522
return error;

Diff for: ‎lldb/source/Commands/CommandObjectCommands.cpp

+6-18
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ class CommandObjectCommandsHistory : public CommandObjectParsed {
8585
m_clear.SetOptionWasSet();
8686
break;
8787
default:
88-
error.SetErrorStringWithFormat("unrecognized option '%c'",
89-
short_option);
90-
break;
88+
llvm_unreachable("Unimplemented option");
9189
}
9290

9391
return error;
@@ -253,9 +251,7 @@ class CommandObjectCommandsSource : public CommandObjectParsed {
253251
break;
254252

255253
default:
256-
error.SetErrorStringWithFormat("unrecognized option '%c'",
257-
short_option);
258-
break;
254+
llvm_unreachable("Unimplemented option");
259255
}
260256

261257
return error;
@@ -370,9 +366,7 @@ class CommandObjectCommandsAlias : public CommandObjectRaw {
370366
break;
371367

372368
default:
373-
error.SetErrorStringWithFormat("invalid short option character '%c'",
374-
short_option);
375-
break;
369+
llvm_unreachable("Unimplemented option");
376370
}
377371

378372
return error;
@@ -1161,9 +1155,7 @@ a number follows 'f':"
11611155
m_syntax.assign(option_arg);
11621156
break;
11631157
default:
1164-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1165-
short_option);
1166-
break;
1158+
llvm_unreachable("Unimplemented option");
11671159
}
11681160

11691161
return error;
@@ -1414,9 +1406,7 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
14141406
m_allow_reload = true;
14151407
break;
14161408
default:
1417-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1418-
short_option);
1419-
break;
1409+
llvm_unreachable("Unimplemented option");
14201410
}
14211411

14221412
return error;
@@ -1568,9 +1558,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
15681558
option_arg.str().c_str());
15691559
break;
15701560
default:
1571-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1572-
short_option);
1573-
break;
1561+
llvm_unreachable("Unimplemented option");
15741562
}
15751563

15761564
return error;

Diff for: ‎lldb/source/Commands/CommandObjectDisassemble.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
147147
} break;
148148

149149
default:
150-
error.SetErrorStringWithFormat("unrecognized short option '%c'",
151-
short_option);
152-
break;
150+
llvm_unreachable("Unimplemented option");
153151
}
154152

155153
return error;

Diff for: ‎lldb/source/Commands/CommandObjectExpression.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue(
166166
}
167167

168168
default:
169-
error.SetErrorStringWithFormat("invalid short option character '%c'",
170-
short_option);
171-
break;
169+
llvm_unreachable("Unimplemented option");
172170
}
173171

174172
return error;

Diff for: ‎lldb/source/Commands/CommandObjectFrame.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ class CommandObjectFrameDiagnose : public CommandObjectParsed {
9292
} break;
9393

9494
default:
95-
error.SetErrorStringWithFormat("invalid short option character '%c'",
96-
short_option);
97-
break;
95+
llvm_unreachable("Unimplemented option");
9896
}
9997

10098
return error;
@@ -257,9 +255,7 @@ class CommandObjectFrameSelect : public CommandObjectParsed {
257255
break;
258256

259257
default:
260-
error.SetErrorStringWithFormat("invalid short option character '%c'",
261-
short_option);
262-
break;
258+
llvm_unreachable("Unimplemented option");
263259
}
264260

265261
return error;
@@ -763,9 +759,7 @@ class CommandObjectFrameRecognizerAdd : public CommandObjectParsed {
763759
m_regex = true;
764760
break;
765761
default:
766-
error.SetErrorStringWithFormat("unrecognized option '%c'",
767-
short_option);
768-
break;
762+
llvm_unreachable("Unimplemented option");
769763
}
770764

771765
return error;

Diff for: ‎lldb/source/Commands/CommandObjectHelp.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ class CommandObjectHelp : public CommandObjectParsed {
5252
m_show_hidden = true;
5353
break;
5454
default:
55-
error.SetErrorStringWithFormat("unrecognized option '%c'",
56-
short_option);
57-
break;
55+
llvm_unreachable("Unimplemented option");
5856
}
5957

6058
return error;

Diff for: ‎lldb/source/Commands/CommandObjectLog.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ class CommandObjectLogEnable : public CommandObjectParsed {
113113
log_options |= LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION;
114114
break;
115115
default:
116-
error.SetErrorStringWithFormat("unrecognized option '%c'",
117-
short_option);
118-
break;
116+
llvm_unreachable("Unimplemented option");
119117
}
120118

121119
return error;

Diff for: ‎lldb/source/Commands/CommandObjectMemory.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ class OptionGroupReadMemory : public OptionGroup {
9696
break;
9797

9898
default:
99-
error.SetErrorStringWithFormat("unrecognized short option '%c'",
100-
short_option);
101-
break;
99+
llvm_unreachable("Unimplemented option");
102100
}
103101
return error;
104102
}
@@ -936,9 +934,7 @@ class CommandObjectMemoryFind : public CommandObjectParsed {
936934
break;
937935

938936
default:
939-
error.SetErrorStringWithFormat("unrecognized short option '%c'",
940-
short_option);
941-
break;
937+
llvm_unreachable("Unimplemented option");
942938
}
943939
return error;
944940
}
@@ -1226,9 +1222,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed {
12261222
} break;
12271223

12281224
default:
1229-
error.SetErrorStringWithFormat("unrecognized short option '%c'",
1230-
short_option);
1231-
break;
1225+
llvm_unreachable("Unimplemented option");
12321226
}
12331227
return error;
12341228
}

Diff for: ‎lldb/source/Commands/CommandObjectPlatform.cpp

+6-17
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ class OptionPermissions : public OptionGroup {
117117
m_permissions |= lldb::eFilePermissionsWorldExecute;
118118
break;
119119
default:
120-
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
121-
break;
120+
llvm_unreachable("Unimplemented option");
122121
}
123122

124123
return error;
@@ -632,9 +631,7 @@ class CommandObjectPlatformFRead : public CommandObjectParsed {
632631
option_arg.str().c_str());
633632
break;
634633
default:
635-
error.SetErrorStringWithFormat("unrecognized option '%c'",
636-
short_option);
637-
break;
634+
llvm_unreachable("Unimplemented option");
638635
}
639636

640637
return error;
@@ -718,9 +715,7 @@ class CommandObjectPlatformFWrite : public CommandObjectParsed {
718715
m_data.assign(option_arg);
719716
break;
720717
default:
721-
error.SetErrorStringWithFormat("unrecognized option '%c'",
722-
short_option);
723-
break;
718+
llvm_unreachable("Unimplemented option");
724719
}
725720

726721
return error;
@@ -1270,9 +1265,7 @@ class CommandObjectPlatformProcessList : public CommandObjectParsed {
12701265
break;
12711266

12721267
default:
1273-
error.SetErrorStringWithFormat("unrecognized option '%c'",
1274-
short_option);
1275-
break;
1268+
llvm_unreachable("Unimplemented option");
12761269
}
12771270

12781271
return error;
@@ -1426,9 +1419,7 @@ class CommandObjectPlatformProcessAttach : public CommandObjectParsed {
14261419
break;
14271420

14281421
default:
1429-
error.SetErrorStringWithFormat("invalid short option character '%c'",
1430-
short_option);
1431-
break;
1422+
llvm_unreachable("Unimplemented option");
14321423
}
14331424
return error;
14341425
}
@@ -1587,9 +1578,7 @@ class CommandObjectPlatformShell : public CommandObjectRaw {
15871578
timeout = std::chrono::seconds(timeout_sec);
15881579
break;
15891580
default:
1590-
error.SetErrorStringWithFormat("invalid short option character '%c'",
1591-
short_option);
1592-
break;
1581+
llvm_unreachable("Unimplemented option");
15931582
}
15941583

15951584
return error;

0 commit comments

Comments
 (0)
Please sign in to comment.