aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 12a8d0c..9491ec0 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -101,6 +101,7 @@ void parser<unsigned long long>::anchor() {}
void parser<double>::anchor() {}
void parser<float>::anchor() {}
void parser<std::string>::anchor() {}
+void parser<std::optional<std::string>>::anchor() {}
void parser<char>::anchor() {}
// These anchor functions instantiate opt<T> and reference its virtual
@@ -2261,6 +2262,22 @@ void parser<std::string>::printOptionDiff(const Option &O, StringRef V,
outs() << ")\n";
}
+void parser<std::optional<std::string>>::printOptionDiff(
+ const Option &O, std::optional<StringRef> V,
+ const OptionValue<std::optional<std::string>> &D,
+ size_t GlobalWidth) const {
+ printOptionName(O, GlobalWidth);
+ outs() << "= " << V;
+ size_t VSize = V.has_value() ? V.value().size() : 0;
+ size_t NumSpaces = MaxOptWidth > VSize ? MaxOptWidth - VSize : 0;
+ outs().indent(NumSpaces) << " (default: ";
+ if (D.hasValue() && D.getValue().has_value())
+ outs() << D.getValue();
+ else
+ outs() << "*no value*";
+ outs() << ")\n";
+}
+
// Print a placeholder for options that don't yet support printOptionDiff().
void basic_parser_impl::printOptionNoValue(const Option &O,
size_t GlobalWidth) const {