[swift-api-digester] Put command-line flags in their own category (#24178)

Previously, swift-api-digester -help would print a bunch of unrelated
LLVM and SIL command-line flags. Putting these in their own category
limits the help output to the specific set of flags swift-api-digester
recognizes.
This commit is contained in:
Harlan Haskins
2019-04-22 09:58:01 -07:00
committed by GitHub
parent 904ba9bafe
commit 0785fd797b

View File

@@ -53,66 +53,87 @@ namespace {
namespace options {
static llvm::cl::OptionCategory Category("swift-api-digester Options");
static llvm::cl::opt<bool>
IncludeAllModules("include-all", llvm::cl::desc("Include all modules from the SDK"));
IncludeAllModules("include-all",
llvm::cl::desc("Include all modules from the SDK"),
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
ModuleNames("module", llvm::cl::ZeroOrMore, llvm::cl::desc("Names of modules"));
ModuleNames("module", llvm::cl::ZeroOrMore, llvm::cl::desc("Names of modules"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
ModuleList("module-list-file",
llvm::cl::desc("File containing a new-line separated list of modules"));
llvm::cl::desc("File containing a new-line separated list of modules"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
ProtReqWhiteList("protocol-requirement-white-list",
llvm::cl::desc("File containing a new-line separated list of protocol names"));
llvm::cl::desc("File containing a new-line separated list of protocol names"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
OutputFile("o", llvm::cl::desc("Output file"));
OutputFile("o", llvm::cl::desc("Output file"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
SDK("sdk", llvm::cl::desc("path to the SDK to build against"));
SDK("sdk", llvm::cl::desc("path to the SDK to build against"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
Triple("target", llvm::cl::desc("target triple"));
Triple("target", llvm::cl::desc("target triple"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
ModuleCachePath("module-cache-path", llvm::cl::desc("Clang module cache path"));
ModuleCachePath("module-cache-path", llvm::cl::desc("Clang module cache path"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
ResourceDir("resource-dir",
llvm::cl::desc("The directory that holds the compiler resource files"));
llvm::cl::desc("The directory that holds the compiler resource files"),
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path"));
FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path"),
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
ModuleInputPaths("I", llvm::cl::desc("add a module for input"));
ModuleInputPaths("I", llvm::cl::desc("add a module for input"),
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
CCSystemFrameworkPaths("iframework",
llvm::cl::desc("add a directory to the clang importer system framework search path"));
llvm::cl::desc("add a directory to the clang importer system framework search path"),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
AbortOnModuleLoadFailure("abort-on-module-fail",
llvm::cl::desc("Abort if a module failed to load"));
llvm::cl::desc("Abort if a module failed to load"),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
Verbose("v", llvm::cl::desc("Verbose"));
Verbose("v", llvm::cl::desc("Verbose"),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
Abi("abi", llvm::cl::desc("Dumping ABI interface"), llvm::cl::init(false));
Abi("abi", llvm::cl::desc("Dumping ABI interface"), llvm::cl::init(false),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
SwiftOnly("swift-only",
llvm::cl::desc("Only include APIs defined from Swift source"),
llvm::cl::init(false));
llvm::cl::init(false),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
PrintModule("print-module", llvm::cl::desc("Print module names in diagnostics"));
PrintModule("print-module", llvm::cl::desc("Print module names in diagnostics"),
llvm::cl::cat(Category));
static llvm::cl::opt<ActionType>
Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
llvm::cl::cat(Category),
llvm::cl::values(
clEnumValN(ActionType::DumpSDK,
"dump-sdk",
@@ -141,32 +162,39 @@ Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
static llvm::cl::list<std::string>
SDKJsonPaths("input-paths",
llvm::cl::desc("The SDK contents under comparison"));
llvm::cl::desc("The SDK contents under comparison"),
llvm::cl::cat(Category));
static llvm::cl::list<std::string>
ApisPrintUsrs("api-usrs",
llvm::cl::desc("The name of APIs to print their usrs, "
"e.g. Type::Function"));
"e.g. Type::Function"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
IgnoreRemovedDeclUSRs("ignored-usrs",
llvm::cl::desc("the file containing USRs of removed decls "
"that the digester should ignore"));
"that the digester should ignore"),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
SwiftVersion("swift-version",
llvm::cl::desc("The Swift compiler version to invoke"));
llvm::cl::desc("The Swift compiler version to invoke"),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
OutputInJson("json", llvm::cl::desc("Print output in JSON format."));
OutputInJson("json", llvm::cl::desc("Print output in JSON format."),
llvm::cl::cat(Category));
static llvm::cl::opt<bool>
AvoidLocation("avoid-location",
llvm::cl::desc("Avoid serializing the file paths of SDK nodes."));
llvm::cl::desc("Avoid serializing the file paths of SDK nodes."),
llvm::cl::cat(Category));
static llvm::cl::opt<std::string>
LocationFilter("location",
llvm::cl::desc("Filter nodes with the given location."));
llvm::cl::desc("Filter nodes with the given location."),
llvm::cl::cat(Category));
} // namespace options
namespace {
@@ -2336,6 +2364,7 @@ int main(int argc, char *argv[]) {
PROGRAM_START(argc, argv);
INITIALIZE_LLVM();
llvm::cl::HideUnrelatedOptions(options::Category);
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SDK Digester\n");
CompilerInvocation InitInvok;