@@ -138,46 +138,6 @@ void Options::OptionsSetUnion(const OptionSet &set_a, const OptionSet &set_b,
138138 }
139139}
140140
141- bool Options::VerifyOptions (CommandReturnObject &result) {
142- bool options_are_valid = false ;
143-
144- int num_levels = GetRequiredOptions ().size ();
145- if (num_levels) {
146- for (int i = 0 ; i < num_levels && !options_are_valid; ++i) {
147- // This is the correct set of options if: 1). m_seen_options contains
148- // all of m_required_options[i] (i.e. all the required options at this
149- // level are a subset of m_seen_options); AND 2). { m_seen_options -
150- // m_required_options[i] is a subset of m_options_options[i] (i.e. all
151- // the rest of m_seen_options are in the set of optional options at this
152- // level.
153-
154- // Check to see if all of m_required_options[i] are a subset of
155- // m_seen_options
156- if (IsASubset (GetRequiredOptions ()[i], m_seen_options)) {
157- // Construct the set difference: remaining_options = {m_seen_options} -
158- // {m_required_options[i]}
159- OptionSet remaining_options;
160- OptionsSetDiff (m_seen_options, GetRequiredOptions ()[i],
161- remaining_options);
162- // Check to see if remaining_options is a subset of
163- // m_optional_options[i]
164- if (IsASubset (remaining_options, GetOptionalOptions ()[i]))
165- options_are_valid = true ;
166- }
167- }
168- } else {
169- options_are_valid = true ;
170- }
171-
172- if (options_are_valid) {
173- result.SetStatus (eReturnStatusSuccessFinishNoResult);
174- } else {
175- result.AppendError (" invalid combination of options for the given command" );
176- }
177-
178- return options_are_valid;
179- }
180-
181141// This is called in the Options constructor, though we could call it lazily if
182142// that ends up being a performance problem.
183143
@@ -590,13 +550,50 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject &cmd,
590550 strm.SetIndentLevel (save_indent_level);
591551}
592552
553+ llvm::Error Options::VerifyOptions () {
554+ bool options_are_valid = false ;
555+
556+ int num_levels = GetRequiredOptions ().size ();
557+ if (num_levels) {
558+ for (int i = 0 ; i < num_levels && !options_are_valid; ++i) {
559+ // This is the correct set of options if: 1). m_seen_options contains
560+ // all of m_required_options[i] (i.e. all the required options at this
561+ // level are a subset of m_seen_options); AND 2). { m_seen_options -
562+ // m_required_options[i] is a subset of m_options_options[i] (i.e. all
563+ // the rest of m_seen_options are in the set of optional options at this
564+ // level.
565+
566+ // Check to see if all of m_required_options[i] are a subset of
567+ // m_seen_options
568+ if (IsASubset (GetRequiredOptions ()[i], m_seen_options)) {
569+ // Construct the set difference: remaining_options = {m_seen_options} -
570+ // {m_required_options[i]}
571+ OptionSet remaining_options;
572+ OptionsSetDiff (m_seen_options, GetRequiredOptions ()[i],
573+ remaining_options);
574+ // Check to see if remaining_options is a subset of
575+ // m_optional_options[i]
576+ if (IsASubset (remaining_options, GetOptionalOptions ()[i]))
577+ options_are_valid = true ;
578+ }
579+ }
580+ } else {
581+ options_are_valid = true ;
582+ }
583+
584+ if (!options_are_valid)
585+ return llvm::createStringError (
586+ " invalid combination of options for the given command" );
587+
588+ return llvm::Error::success ();
589+ }
590+
593591// This function is called when we have been given a potentially incomplete set
594592// of options, such as when an alias has been defined (more options might be
595593// added at at the time the alias is invoked). We need to verify that the
596594// options in the set m_seen_options are all part of a set that may be used
597595// together, but m_seen_options may be missing some of the "required" options.
598-
599- bool Options::VerifyPartialOptions (CommandReturnObject &result) {
596+ llvm::Error Options::VerifyPartialOptions () {
600597 bool options_are_valid = false ;
601598
602599 int num_levels = GetRequiredOptions ().size ();
@@ -613,7 +610,11 @@ bool Options::VerifyPartialOptions(CommandReturnObject &result) {
613610 }
614611 }
615612
616- return options_are_valid;
613+ if (!options_are_valid)
614+ return llvm::createStringError (
615+ " invalid combination of options for the given command" );
616+
617+ return llvm::Error::success ();
617618}
618619
619620bool Options::HandleOptionCompletion (CompletionRequest &request,
0 commit comments