@@ -238,6 +238,8 @@ void emitOptionWithArgs(StringRef Prefix, const Record *Option,
238
238
}
239
239
}
240
240
241
+ constexpr StringLiteral DefaultMetaVarName = " <arg>" ;
242
+
241
243
void emitOptionName (StringRef Prefix, const Record *Option, raw_ostream &OS) {
242
244
// Find the arguments to list after the option.
243
245
unsigned NumArgs = getNumArgsForKind (Option->getValueAsDef (" Kind" ), Option);
@@ -247,7 +249,7 @@ void emitOptionName(StringRef Prefix, const Record *Option, raw_ostream &OS) {
247
249
if (HasMetaVarName)
248
250
Args.push_back (std::string (Option->getValueAsString (" MetaVarName" )));
249
251
else if (NumArgs == 1 )
250
- Args.push_back (" <arg> " );
252
+ Args.push_back (DefaultMetaVarName. str () );
251
253
252
254
// Fill up arguments if this option didn't provide a meta var name or it
253
255
// supports an unlimited number of arguments. We can't see how many arguments
@@ -341,8 +343,30 @@ void emitOption(const DocumentedOption &Option, const Record *DocInfo,
341
343
OS << " \n\n " ;
342
344
343
345
// Emit the description, if we have one.
346
+ const Record *R = Option.Option ;
344
347
std::string Description =
345
- getRSTStringWithTextFallback (Option.Option , " DocBrief" , " HelpText" );
348
+ getRSTStringWithTextFallback (R, " DocBrief" , " HelpText" );
349
+
350
+ if (!isa<UnsetInit>(R->getValueInit (" Values" ))) {
351
+ if (!Description.empty () && Description.back () != ' .' )
352
+ Description.push_back (' .' );
353
+
354
+ StringRef MetaVarName;
355
+ if (!isa<UnsetInit>(R->getValueInit (" MetaVarName" )))
356
+ MetaVarName = R->getValueAsString (" MetaVarName" );
357
+ else
358
+ MetaVarName = DefaultMetaVarName;
359
+
360
+ SmallVector<StringRef> Values;
361
+ SplitString (R->getValueAsString (" Values" ), Values, " ," );
362
+ Description += (" " + MetaVarName + " must be '" ).str ();
363
+ if (Values.size () > 1 ) {
364
+ Description += join (Values.begin (), Values.end () - 1 , " ', '" );
365
+ Description += " ' or '" ;
366
+ }
367
+ Description += (Values.back () + " '." ).str ();
368
+ }
369
+
346
370
if (!Description.empty ())
347
371
OS << Description << " \n\n " ;
348
372
}
0 commit comments