Option.h revision b32aa51ce9b608002a031e8ca682f073e28024cf
11eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar//===--- Option.h - Abstract Driver Options ---------------------*- C++ -*-===//
21eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar//
31eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar//                     The LLVM Compiler Infrastructure
41eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar//
51eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar// This file is distributed under the University of Illinois Open Source
61eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar// License. See LICENSE.TXT for details.
71eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar//
81eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar//===----------------------------------------------------------------------===//
91eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
101eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar#ifndef CLANG_DRIVER_OPTION_H_
111eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar#define CLANG_DRIVER_OPTION_H_
121eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
132c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar#include "llvm/Support/Casting.h"
142c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbarusing llvm::isa;
152c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbarusing llvm::cast;
162c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbarusing llvm::cast_or_null;
172c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbarusing llvm::dyn_cast;
182c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbarusing llvm::dyn_cast_or_null;
192c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
201eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbarnamespace clang {
211eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbarnamespace driver {
221eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class Arg;
23f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar  class InputArgList;
241eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class OptionGroup;
251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
261eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// Option - Abstract representation for a single form of driver
271eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// argument.
281eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  ///
291eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// An Option class represents a form of option that the driver
301eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// takes, for example how many arguments the option has and how
311eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// they can be provided. Individual option instances store
321eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// additional information about what group the option is a member
331eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// of (if any), if the option is an alias, and a number of
341eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// flags. At runtime the driver parses the command line into
351eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// concrete Arg instances, each of which corresponds to a
361eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// particular Option instance.
371eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class Option {
381eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  public:
391eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    enum OptionClass {
402c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      GroupClass = 0,
412c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      InputClass,
422c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      UnknownClass,
432c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      FlagClass,
442c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      JoinedClass,
452c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      SeparateClass,
462c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      CommaJoinedClass,
472c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      MultiArgClass,
482c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      JoinedOrSeparateClass,
492c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar      JoinedAndSeparateClass
501eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    };
511eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
521eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  private:
531eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    OptionClass Kind;
541eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
551d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    unsigned ID;
5630b055f553ffa50ae5413ecf0f0ac8061c58f475Daniel Dunbar
571eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// The option name.
581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    const char *Name;
591eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
601eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// Group this option is a member of, if any.
611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    const OptionGroup *Group;
621eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
631eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// Option that this is an alias for, if any.
641eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    const Option *Alias;
651eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
660f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    /// Unsupported options will not be rejected.
670f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    bool Unsupported : 1;
680f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
690f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    /// Treat this option like a linker input?
700f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    bool LinkerInput : 1;
711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
720f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    /// When rendering as an input, don't render the option.
730f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
740f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    // FIXME: We should ditch the render/renderAsInput distinction.
750f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    bool NoOptAsInput : 1;
760f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
770f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    /// Always render this option as separate form its value.
780f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    bool ForceSeparateRender : 1;
791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
800f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    /// Always render this option joined with its value.
811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    bool ForceJoinedRender : 1;
820f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
831e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar    /// This option is only consumed by the driver.
841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    bool DriverOption : 1;
856d954d788925e6b80077ef379c8eeb028cc31d0eDaniel Dunbar
861e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar    /// This option should not report argument unused errors.
871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    bool NoArgumentUnused : 1;
881e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar
891eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  protected:
901d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    Option(OptionClass Kind, unsigned ID, const char *Name,
912c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar           const OptionGroup *Group, const Option *Alias);
92d35e63106d7b4b76275c85c88ee715c4356f2a6bDaniel Dunbar  public:
93d35e63106d7b4b76275c85c88ee715c4356f2a6bDaniel Dunbar    virtual ~Option();
941eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
951d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    unsigned getId() const { return ID; }
961eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    OptionClass getKind() const { return Kind; }
971eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    const char *getName() const { return Name; }
981eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    const OptionGroup *getGroup() const { return Group; }
991eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    const Option *getAlias() const { return Alias; }
1001eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
1010f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    bool isUnsupported() const { return Unsupported; }
1020f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    void setUnsupported(bool Value) { Unsupported = Value; }
1030f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
1040f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    bool isLinkerInput() const { return LinkerInput; }
1050f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    void setLinkerInput(bool Value) { LinkerInput = Value; }
1060f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
1076d954d788925e6b80077ef379c8eeb028cc31d0eDaniel Dunbar    bool hasNoOptAsInput() const { return NoOptAsInput; }
1080f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    void setNoOptAsInput(bool Value) { NoOptAsInput = Value; }
1091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1106d954d788925e6b80077ef379c8eeb028cc31d0eDaniel Dunbar    bool hasForceSeparateRender() const { return ForceSeparateRender; }
1110f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    void setForceSeparateRender(bool Value) { ForceSeparateRender = Value; }
1121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1136d954d788925e6b80077ef379c8eeb028cc31d0eDaniel Dunbar    bool hasForceJoinedRender() const { return ForceJoinedRender; }
1140f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar    void setForceJoinedRender(bool Value) { ForceJoinedRender = Value; }
1151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
116f6dd66b7b80e2fb42628df2593b3948149a53a5fDaniel Dunbar    bool isDriverOption() const { return DriverOption; }
117f6dd66b7b80e2fb42628df2593b3948149a53a5fDaniel Dunbar    void setDriverOption(bool Value) { DriverOption = Value; }
118f6dd66b7b80e2fb42628df2593b3948149a53a5fDaniel Dunbar
1191e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar    bool hasNoArgumentUnused() const { return NoArgumentUnused; }
1201e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar    void setNoArgumentUnused(bool Value) { NoArgumentUnused = Value; }
1211e23f5f963dd6a3cee43ace77578161798e41e2dDaniel Dunbar
122f6dd66b7b80e2fb42628df2593b3948149a53a5fDaniel Dunbar    bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }
1230f9098e093089e935066729ea06bc86c23d9a432Daniel Dunbar
1241eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// getUnaliasedOption - Return the final option this option
1251eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// aliases (itself, if the option has no alias).
1261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    const Option *getUnaliasedOption() const {
1271eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar      if (Alias) return Alias->getUnaliasedOption();
1281eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar      return this;
1291eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    }
1301eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
1311eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// getRenderName - Return the name to use when rendering this
1321eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// option.
1331eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    const char *getRenderName() const {
1341eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar      return getUnaliasedOption()->getName();
1351eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    }
1361eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
1371eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// matches - Predicate for whether this option is part of the
1381eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// given option (which may be a group).
139b32aa51ce9b608002a031e8ca682f073e28024cfDaniel Dunbar    ///
140b32aa51ce9b608002a031e8ca682f073e28024cfDaniel Dunbar    /// Note that matches against options which are an alias should never be
141b32aa51ce9b608002a031e8ca682f073e28024cfDaniel Dunbar    /// done -- aliases do not participate in matching and so such a query will
142b32aa51ce9b608002a031e8ca682f073e28024cfDaniel Dunbar    /// always be false.
1431eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    bool matches(const Option *Opt) const;
1441d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    bool matches(unsigned Id) const;
1451eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
1461eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// accept - Potentially accept the current argument, returning a
1471eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    /// new Arg instance, or 0 if the option does not accept this
148b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    /// argument (or the argument is missing values).
1491eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    ///
150b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    /// If the option accepts the current argument, accept() sets
151b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    /// Index to the position where argument parsing should resume
152b0c4df5c4df69a003f26b378eb95961bc7c486e5Daniel Dunbar    /// (even if the argument is missing values).
153f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const = 0;
1541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1552c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    void dump() const;
1562c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
1572c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const Option *) { return true; }
1581eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
1591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1601eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// OptionGroup - A set of options which are can be handled uniformly
1611eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// by the driver.
1621eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class OptionGroup : public Option {
1631eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  public:
1641d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    OptionGroup(unsigned ID, const char *Name, const OptionGroup *Group);
1651eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
166f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
1672c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
1681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
1691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::GroupClass;
1702c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
1712c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const OptionGroup *) { return true; }
1721eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
1731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1741eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  // Dummy option classes.
1751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump
1761eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// InputOption - Dummy option class for representing driver inputs.
1771eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class InputOption : public Option {
1781eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  public:
1791eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    InputOption();
1801eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
181f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
1822c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
1831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
1841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::InputClass;
1852c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
1862c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const InputOption *) { return true; }
1871eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
1881eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
1891eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// UnknownOption - Dummy option class for represent unknown arguments.
1901eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class UnknownOption : public Option {
1911eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  public:
1921eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    UnknownOption();
1931eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
194f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
1952c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
1961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
1971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::UnknownClass;
1982c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
1992c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const UnknownOption *) { return true; }
2001eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2011eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2021eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  // Normal options.
2031eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2041eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class FlagOption : public Option {
2051eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  public:
2061d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    FlagOption(unsigned ID, const char *Name, const OptionGroup *Group,
20730b055f553ffa50ae5413ecf0f0ac8061c58f475Daniel Dunbar               const Option *Alias);
2081eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
209f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
2102c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
2111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
2121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::FlagClass;
2132c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
2142c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const FlagOption *) { return true; }
2151eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2161eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2171eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class JoinedOption : public Option {
2182c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  public:
2191d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    JoinedOption(unsigned ID, const char *Name, const OptionGroup *Group,
2202c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar                 const Option *Alias);
2211eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
222f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
2232c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
2241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
2251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::JoinedClass;
2262c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
2272c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const JoinedOption *) { return true; }
2281eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2291eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2302c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  class SeparateOption : public Option {
2312c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  public:
2321d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    SeparateOption(unsigned ID, const char *Name, const OptionGroup *Group,
2332c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar                   const Option *Alias);
2341eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
235f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
2362c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
2371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
2381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::SeparateClass;
2392c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
2402c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const SeparateOption *) { return true; }
2411eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2421eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2432c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  class CommaJoinedOption : public Option {
2442c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  public:
2451d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    CommaJoinedOption(unsigned ID, const char *Name,
24630b055f553ffa50ae5413ecf0f0ac8061c58f475Daniel Dunbar                      const OptionGroup *Group, const Option *Alias);
2471eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
248f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
2492c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
2501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
2511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::CommaJoinedClass;
2522c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
2532c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const CommaJoinedOption *) { return true; }
2541eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2551eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2563c9cc6bfe933766a8b4177a3f69841b2344ec48aDaniel Dunbar  // FIXME: Fold MultiArgOption into SeparateOption?
2573c9cc6bfe933766a8b4177a3f69841b2344ec48aDaniel Dunbar
2581eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// MultiArgOption - An option which takes multiple arguments (these
2591eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// are always separate arguments).
2601eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class MultiArgOption : public Option {
2611eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    unsigned NumArgs;
2621eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2631eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  public:
2641d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    MultiArgOption(unsigned ID, const char *Name, const OptionGroup *Group,
2652c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar                   const Option *Alias, unsigned NumArgs);
2661eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2671eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar    unsigned getNumArgs() const { return NumArgs; }
2681eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
269f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
2702c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
2711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
2721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::MultiArgClass;
2732c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
2742c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const MultiArgOption *) { return true; }
2751eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2761eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2771eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// JoinedOrSeparateOption - An option which either literally
2781eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// prefixes its (non-empty) value, or is follwed by a value.
2791eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class JoinedOrSeparateOption : public Option {
2802c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  public:
2811d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    JoinedOrSeparateOption(unsigned ID, const char *Name,
28230b055f553ffa50ae5413ecf0f0ac8061c58f475Daniel Dunbar                           const OptionGroup *Group, const Option *Alias);
2831eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
284f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
2852c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
2861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
2871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::JoinedOrSeparateClass;
2882c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
2892c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const JoinedOrSeparateOption *) { return true; }
2901eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
2911eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
2921eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// JoinedAndSeparateOption - An option which literally prefixes its
2931eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  /// value and is followed by another value.
2941eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  class JoinedAndSeparateOption : public Option {
2952c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar  public:
2961d189e187b1bf7d7677aefd7482bcdad29683a0cDaniel Dunbar    JoinedAndSeparateOption(unsigned ID, const char *Name,
29730b055f553ffa50ae5413ecf0f0ac8061c58f475Daniel Dunbar                            const OptionGroup *Group, const Option *Alias);
2981eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
299f3cad36e59a41b5767fe662b5ac8911ee174b801Daniel Dunbar    virtual Arg *accept(const InputArgList &Args, unsigned &Index) const;
3002c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar
3011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump    static bool classof(const Option *O) {
3021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump      return O->getKind() == Option::JoinedAndSeparateClass;
3032c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    }
3042c6f6f3c170502c5b810102cf85f05732a2aa9d0Daniel Dunbar    static bool classof(const JoinedAndSeparateOption *) { return true; }
3051eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar  };
3061eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
3071eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar} // end namespace driver
3081eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar} // end namespace clang
3091eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar
3101eb4e64eed08837b85a375d6a953503daa844f07Daniel Dunbar#endif
311