Skip to content

Commit 0785fd7

Browse files
author
Harlan Haskins
authored
[swift-api-digester] Put command-line flags in their own category (swiftlang#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.
1 parent 904ba9b commit 0785fd7

File tree

1 file changed

+53
-24
lines changed

1 file changed

+53
-24
lines changed

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,66 +53,87 @@ namespace {
5353

5454
namespace options {
5555

56+
static llvm::cl::OptionCategory Category("swift-api-digester Options");
57+
5658
static llvm::cl::opt<bool>
57-
IncludeAllModules("include-all", llvm::cl::desc("Include all modules from the SDK"));
59+
IncludeAllModules("include-all",
60+
llvm::cl::desc("Include all modules from the SDK"),
61+
llvm::cl::cat(Category));
5862

5963
static llvm::cl::list<std::string>
60-
ModuleNames("module", llvm::cl::ZeroOrMore, llvm::cl::desc("Names of modules"));
64+
ModuleNames("module", llvm::cl::ZeroOrMore, llvm::cl::desc("Names of modules"),
65+
llvm::cl::cat(Category));
6166

6267
static llvm::cl::opt<std::string>
6368
ModuleList("module-list-file",
64-
llvm::cl::desc("File containing a new-line separated list of modules"));
69+
llvm::cl::desc("File containing a new-line separated list of modules"),
70+
llvm::cl::cat(Category));
6571

6672
static llvm::cl::opt<std::string>
6773
ProtReqWhiteList("protocol-requirement-white-list",
68-
llvm::cl::desc("File containing a new-line separated list of protocol names"));
74+
llvm::cl::desc("File containing a new-line separated list of protocol names"),
75+
llvm::cl::cat(Category));
6976

7077
static llvm::cl::opt<std::string>
71-
OutputFile("o", llvm::cl::desc("Output file"));
78+
OutputFile("o", llvm::cl::desc("Output file"),
79+
llvm::cl::cat(Category));
7280

7381
static llvm::cl::opt<std::string>
74-
SDK("sdk", llvm::cl::desc("path to the SDK to build against"));
82+
SDK("sdk", llvm::cl::desc("path to the SDK to build against"),
83+
llvm::cl::cat(Category));
7584

7685
static llvm::cl::opt<std::string>
77-
Triple("target", llvm::cl::desc("target triple"));
86+
Triple("target", llvm::cl::desc("target triple"),
87+
llvm::cl::cat(Category));
7888

7989
static llvm::cl::opt<std::string>
80-
ModuleCachePath("module-cache-path", llvm::cl::desc("Clang module cache path"));
90+
ModuleCachePath("module-cache-path", llvm::cl::desc("Clang module cache path"),
91+
llvm::cl::cat(Category));
8192

8293
static llvm::cl::opt<std::string>
8394
ResourceDir("resource-dir",
84-
llvm::cl::desc("The directory that holds the compiler resource files"));
95+
llvm::cl::desc("The directory that holds the compiler resource files"),
96+
llvm::cl::cat(Category));
8597

8698
static llvm::cl::list<std::string>
87-
FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path"));
99+
FrameworkPaths("F", llvm::cl::desc("add a directory to the framework search path"),
100+
llvm::cl::cat(Category));
88101

89102
static llvm::cl::list<std::string>
90-
ModuleInputPaths("I", llvm::cl::desc("add a module for input"));
103+
ModuleInputPaths("I", llvm::cl::desc("add a module for input"),
104+
llvm::cl::cat(Category));
91105

92106
static llvm::cl::list<std::string>
93107
CCSystemFrameworkPaths("iframework",
94-
llvm::cl::desc("add a directory to the clang importer system framework search path"));
108+
llvm::cl::desc("add a directory to the clang importer system framework search path"),
109+
llvm::cl::cat(Category));
95110

96111
static llvm::cl::opt<bool>
97112
AbortOnModuleLoadFailure("abort-on-module-fail",
98-
llvm::cl::desc("Abort if a module failed to load"));
113+
llvm::cl::desc("Abort if a module failed to load"),
114+
llvm::cl::cat(Category));
99115

100116
static llvm::cl::opt<bool>
101-
Verbose("v", llvm::cl::desc("Verbose"));
117+
Verbose("v", llvm::cl::desc("Verbose"),
118+
llvm::cl::cat(Category));
102119

103120
static llvm::cl::opt<bool>
104-
Abi("abi", llvm::cl::desc("Dumping ABI interface"), llvm::cl::init(false));
121+
Abi("abi", llvm::cl::desc("Dumping ABI interface"), llvm::cl::init(false),
122+
llvm::cl::cat(Category));
105123

106124
static llvm::cl::opt<bool>
107125
SwiftOnly("swift-only",
108126
llvm::cl::desc("Only include APIs defined from Swift source"),
109-
llvm::cl::init(false));
127+
llvm::cl::init(false),
128+
llvm::cl::cat(Category));
110129

111130
static llvm::cl::opt<bool>
112-
PrintModule("print-module", llvm::cl::desc("Print module names in diagnostics"));
131+
PrintModule("print-module", llvm::cl::desc("Print module names in diagnostics"),
132+
llvm::cl::cat(Category));
113133

114134
static llvm::cl::opt<ActionType>
115135
Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
136+
llvm::cl::cat(Category),
116137
llvm::cl::values(
117138
clEnumValN(ActionType::DumpSDK,
118139
"dump-sdk",
@@ -141,32 +162,39 @@ Action(llvm::cl::desc("Mode:"), llvm::cl::init(ActionType::None),
141162

142163
static llvm::cl::list<std::string>
143164
SDKJsonPaths("input-paths",
144-
llvm::cl::desc("The SDK contents under comparison"));
165+
llvm::cl::desc("The SDK contents under comparison"),
166+
llvm::cl::cat(Category));
145167

146168
static llvm::cl::list<std::string>
147169
ApisPrintUsrs("api-usrs",
148170
llvm::cl::desc("The name of APIs to print their usrs, "
149-
"e.g. Type::Function"));
171+
"e.g. Type::Function"),
172+
llvm::cl::cat(Category));
150173

151174
static llvm::cl::opt<std::string>
152175
IgnoreRemovedDeclUSRs("ignored-usrs",
153176
llvm::cl::desc("the file containing USRs of removed decls "
154-
"that the digester should ignore"));
177+
"that the digester should ignore"),
178+
llvm::cl::cat(Category));
155179

156180
static llvm::cl::opt<std::string>
157181
SwiftVersion("swift-version",
158-
llvm::cl::desc("The Swift compiler version to invoke"));
182+
llvm::cl::desc("The Swift compiler version to invoke"),
183+
llvm::cl::cat(Category));
159184

160185
static llvm::cl::opt<bool>
161-
OutputInJson("json", llvm::cl::desc("Print output in JSON format."));
186+
OutputInJson("json", llvm::cl::desc("Print output in JSON format."),
187+
llvm::cl::cat(Category));
162188

163189
static llvm::cl::opt<bool>
164190
AvoidLocation("avoid-location",
165-
llvm::cl::desc("Avoid serializing the file paths of SDK nodes."));
191+
llvm::cl::desc("Avoid serializing the file paths of SDK nodes."),
192+
llvm::cl::cat(Category));
166193

167194
static llvm::cl::opt<std::string>
168195
LocationFilter("location",
169-
llvm::cl::desc("Filter nodes with the given location."));
196+
llvm::cl::desc("Filter nodes with the given location."),
197+
llvm::cl::cat(Category));
170198
} // namespace options
171199

172200
namespace {
@@ -2336,6 +2364,7 @@ int main(int argc, char *argv[]) {
23362364
PROGRAM_START(argc, argv);
23372365
INITIALIZE_LLVM();
23382366

2367+
llvm::cl::HideUnrelatedOptions(options::Category);
23392368
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SDK Digester\n");
23402369
CompilerInvocation InitInvok;
23412370

0 commit comments

Comments
 (0)