@@ -242,13 +242,13 @@ opt<std::string> FallbackStyle{
242242 init (clang::format::DefaultFallbackStyle),
243243};
244244
245- opt<int > EnableFunctionArgSnippets{
245+ opt<std::string > EnableFunctionArgSnippets{
246246 " function-arg-placeholders" ,
247247 cat (Features),
248248 desc (" When disabled (0), completions contain only parentheses for "
249249 " function calls. When enabled (1), completions also contain "
250250 " placeholders for method parameters" ),
251- init (- 1 ),
251+ init (" -1 " ),
252252};
253253
254254opt<CodeCompleteOptions::IncludeInsertion> HeaderInsertion{
@@ -636,6 +636,22 @@ loadExternalIndex(const Config::ExternalIndexSpec &External,
636636 llvm_unreachable (" Invalid ExternalIndexKind." );
637637}
638638
639+ std::optional<bool > shouldEnableFunctionArgSnippets () {
640+ std::string Val = EnableFunctionArgSnippets;
641+ // Accept the same values that a bool option parser would, but also accept
642+ // -1 to indicate "unspecified", in which case the ArgumentListsPolicy
643+ // config option will be respected.
644+ if (Val == " 1" || Val == " true" || Val == " True" || Val == " TRUE" )
645+ return true ;
646+ if (Val == " 0" || Val == " false" || Val == " False" || Val == " FALSE" )
647+ return false ;
648+ if (Val != " -1" )
649+ elog (" Value specified by --function-arg-placeholders is invalid. Provide a "
650+ " boolean value or leave unspecified to use ArgumentListsPolicy from "
651+ " config instead." );
652+ return std::nullopt ;
653+ }
654+
639655class FlagsConfigProvider : public config ::Provider {
640656private:
641657 config::CompiledFragment Frag;
@@ -696,10 +712,9 @@ class FlagsConfigProvider : public config::Provider {
696712 BGPolicy = Config::BackgroundPolicy::Skip;
697713 }
698714
699- if (EnableFunctionArgSnippets >= 0 ) {
700- ArgumentLists = EnableFunctionArgSnippets
701- ? Config::ArgumentListsPolicy::FullPlaceholders
702- : Config::ArgumentListsPolicy::Delimiters;
715+ if (std::optional<bool > Enable = shouldEnableFunctionArgSnippets ()) {
716+ ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
717+ : Config::ArgumentListsPolicy::Delimiters;
703718 }
704719
705720 Frag = [=](const config::Params &, Config &C) {
0 commit comments