Skip to content
Permalink
Browse files

[lldb][NFC] Remove dead code that is supposed to handle invalid comma…

…nd 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
  • Loading branch information
Teemperor committed Aug 22, 2019
1 parent ae34ed2 commit 36162014c4697c30af588197d7cdeb8d2930abbf
Showing with 82 additions and 217 deletions.
  1. +11 −28 lldb/source/Commands/CommandObjectBreakpoint.cpp
  2. +2 −4 lldb/source/Commands/CommandObjectBreakpointCommand.cpp
  3. +6 −18 lldb/source/Commands/CommandObjectCommands.cpp
  4. +1 −3 lldb/source/Commands/CommandObjectDisassemble.cpp
  5. +1 −3 lldb/source/Commands/CommandObjectExpression.cpp
  6. +3 −9 lldb/source/Commands/CommandObjectFrame.cpp
  7. +1 −3 lldb/source/Commands/CommandObjectHelp.h
  8. +1 −3 lldb/source/Commands/CommandObjectLog.cpp
  9. +3 −9 lldb/source/Commands/CommandObjectMemory.cpp
  10. +6 −17 lldb/source/Commands/CommandObjectPlatform.cpp
  11. +6 −18 lldb/source/Commands/CommandObjectProcess.cpp
  12. +1 −3 lldb/source/Commands/CommandObjectRegister.cpp
  13. +3 −9 lldb/source/Commands/CommandObjectSettings.cpp
  14. +2 −6 lldb/source/Commands/CommandObjectSource.cpp
  15. +5 −7 lldb/source/Commands/CommandObjectTarget.cpp
  16. +7 −17 lldb/source/Commands/CommandObjectThread.cpp
  17. +11 −32 lldb/source/Commands/CommandObjectType.cpp
  18. +3 −9 lldb/source/Commands/CommandObjectWatchpoint.cpp
  19. +1 −1 lldb/source/Commands/CommandObjectWatchpointCommand.cpp
  20. +1 −2 lldb/source/Interpreter/OptionGroupArchitecture.cpp
  21. +1 −2 lldb/source/Interpreter/OptionGroupFormat.cpp
  22. +1 −2 lldb/source/Interpreter/OptionGroupOutputFile.cpp
  23. +1 −2 lldb/source/Interpreter/OptionGroupPlatform.cpp
  24. +1 −2 lldb/source/Interpreter/OptionGroupUUID.cpp
  25. +1 −2 lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
  26. +1 −3 lldb/source/Interpreter/OptionGroupVariable.cpp
  27. +1 −3 lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -141,9 +141,7 @@ class lldb_private::BreakpointOptionGroup : public OptionGroup
}
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -206,9 +204,7 @@ class BreakpointDummyOptionGroup : public OptionGroup
m_use_dummy = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -1208,9 +1202,7 @@ class CommandObjectBreakpointList : public CommandObjectParsed {
m_internal = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("unrecognized short option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -1713,7 +1699,8 @@ class BreakpointAccessOptionGroup : public OptionGroup {
"invalid boolean value '%s' passed for -L option",
option_arg.str().c_str());
} break;

default:
llvm_unreachable("Unimplemented option");
}

return error;
@@ -2175,9 +2162,7 @@ class CommandObjectBreakpointRead : public CommandObjectParsed {
break;
}
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -2293,9 +2278,7 @@ class CommandObjectBreakpointWrite : public CommandObjectParsed {
m_append = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -324,7 +324,7 @@ are no syntax errors may indicate that a function was declared but never called.
break;

default:
break;
llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -516,9 +516,7 @@ class CommandObjectBreakpointCommandDelete : public CommandObjectParsed {
break;

default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -85,9 +85,7 @@ class CommandObjectCommandsHistory : public CommandObjectParsed {
m_clear.SetOptionWasSet();
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -1161,9 +1155,7 @@ a number follows 'f':"
m_syntax.assign(option_arg);
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -1414,9 +1406,7 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed {
m_allow_reload = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -1568,9 +1558,7 @@ class CommandObjectCommandsScriptAdd : public CommandObjectParsed,
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -147,9 +147,7 @@ Status CommandObjectDisassemble::CommandOptions::SetOptionValue(
} break;

default:
error.SetErrorStringWithFormat("unrecognized short option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -166,9 +166,7 @@ Status CommandObjectExpression::CommandOptions::SetOptionValue(
}

default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -92,9 +92,7 @@ class CommandObjectFrameDiagnose : public CommandObjectParsed {
} break;

default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -763,9 +759,7 @@ class CommandObjectFrameRecognizerAdd : public CommandObjectParsed {
m_regex = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -52,9 +52,7 @@ class CommandObjectHelp : public CommandObjectParsed {
m_show_hidden = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -113,9 +113,7 @@ class CommandObjectLogEnable : public CommandObjectParsed {
log_options |= LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -96,9 +96,7 @@ class OptionGroupReadMemory : public OptionGroup {
break;

default:
error.SetErrorStringWithFormat("unrecognized short option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -936,9 +934,7 @@ class CommandObjectMemoryFind : public CommandObjectParsed {
break;

default:
error.SetErrorStringWithFormat("unrecognized short option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -1226,9 +1222,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed {
} break;

default:
error.SetErrorStringWithFormat("unrecognized short option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -117,8 +117,7 @@ class OptionPermissions : public OptionGroup {
m_permissions |= lldb::eFilePermissionsWorldExecute;
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;
@@ -632,9 +631,7 @@ class CommandObjectPlatformFRead : public CommandObjectParsed {
option_arg.str().c_str());
break;
default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

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

default:
error.SetErrorStringWithFormat("unrecognized option '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

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

default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}
return error;
}
@@ -1587,9 +1578,7 @@ class CommandObjectPlatformShell : public CommandObjectRaw {
timeout = std::chrono::seconds(timeout_sec);
break;
default:
error.SetErrorStringWithFormat("invalid short option character '%c'",
short_option);
break;
llvm_unreachable("Unimplemented option");
}

return error;

0 comments on commit 3616201

Please sign in to comment.
You can’t perform that action at this time.