@@ -126,7 +126,8 @@ enum MiscFlags { // Miscellaneous flags to adjust argument
126
126
CommaSeparated = 0x200 , // Should this cl::list split between commas?
127
127
PositionalEatsArgs = 0x400 , // Should this positional cl::list eat -args?
128
128
Sink = 0x800 , // Should this cl::list eat all unknown options?
129
- MiscMask = 0xE00 // Union of the above flags.
129
+ AllowInverse = 0x1000 , // Can this option take a -Xno- form?
130
+ MiscMask = 0x1E00 // Union of the above flags.
130
131
};
131
132
132
133
@@ -302,12 +303,6 @@ struct LocationClass {
302
303
template <class Ty >
303
304
LocationClass<Ty> location (Ty &L) { return LocationClass<Ty>(L); }
304
305
305
- // opposite_of - Allow the user to specify which other option this
306
- // option is the opposite of.
307
- //
308
- template <class Ty >
309
- LocationClass<bool > opposite_of (Ty &O) { return location (O.getValue ()); }
310
-
311
306
312
307
// ===----------------------------------------------------------------------===//
313
308
// Enum valued command line option
@@ -542,10 +537,33 @@ struct basic_parser : public basic_parser_impl {
542
537
//
543
538
template <>
544
539
class parser <bool > : public basic_parser<bool > {
540
+ bool IsInvertable; // Should we synthezise a -xno- style option?
541
+ const char *ArgStr;
545
542
public:
543
+ void getExtraOptionNames (std::vector<const char *> &OptionNames) {
544
+ if (IsInvertable) {
545
+ char *s = new char [strlen (ArgStr) + 3 + 1 ];
546
+ s[0 ] = ArgStr[0 ];
547
+ s[1 ] = ' n' ;
548
+ s[2 ] = ' o' ;
549
+ s[3 ] = ' -' ;
550
+ strcpy (&s[4 ], ArgStr+1 );
551
+ OptionNames.push_back (s);
552
+ }
553
+ }
554
+
546
555
// parse - Return true on error.
547
556
bool parse (Option &O, const char *ArgName, const std::string &Arg, bool &Val);
548
557
558
+ template <class Opt >
559
+ void initialize (Opt &O) {
560
+ if (O.getMiscFlags () & llvm::cl::AllowInverse)
561
+ IsInvertable = true ;
562
+ else
563
+ IsInvertable = false ;
564
+ ArgStr = O.ArgStr ;
565
+ }
566
+
549
567
enum ValueExpected getValueExpectedFlagDefault () const {
550
568
return ValueOptional;
551
569
}
@@ -582,30 +600,6 @@ class parser<boolOrDefault> : public basic_parser<boolOrDefault> {
582
600
583
601
EXTERN_TEMPLATE_INSTANTIATION (class basic_parser <boolOrDefault>);
584
602
585
- // --------------------------------------------------
586
- // parser<boolInverse>
587
- class boolInverse { };
588
- template <>
589
- class parser <boolInverse> : public basic_parser<bool > {
590
- public:
591
- typedef bool parser_data_type;
592
- // parse - Return true on error.
593
- bool parse (Option &O, const char *ArgName, const std::string &Arg,
594
- bool &Val);
595
-
596
- enum ValueExpected getValueExpectedFlagDefault () const {
597
- return ValueOptional;
598
- }
599
-
600
- // getValueName - Do not print =<value> at all.
601
- virtual const char *getValueName () const { return 0 ; }
602
-
603
- // An out-of-line virtual method to provide a 'home' for this class.
604
- virtual void anchor ();
605
- };
606
-
607
- EXTERN_TEMPLATE_INSTANTIATION (class basic_parser <bool >);
608
-
609
603
// --------------------------------------------------
610
604
// parser<int>
611
605
//
@@ -947,9 +941,6 @@ EXTERN_TEMPLATE_INSTANTIATION(class opt<int>);
947
941
EXTERN_TEMPLATE_INSTANTIATION (class opt <std::string>);
948
942
EXTERN_TEMPLATE_INSTANTIATION (class opt <bool >);
949
943
950
- class boolInverse ;
951
- typedef opt<bool , true , parser<boolInverse> > inverse_opt;
952
-
953
944
// ===----------------------------------------------------------------------===//
954
945
// list_storage class
955
946
0 commit comments