summaryrefslogtreecommitdiffstats
path: root/include/clang/Driver/Options.h
blob: 8b959d369c0e127a8aef6f482e9c02f3b34bdd0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//===--- Options.h - Option info & table ------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef CLANG_DRIVER_OPTIONS_H_
#define CLANG_DRIVER_OPTIONS_H_

namespace clang {
namespace driver {
namespace options {
  enum ID {
    OPT_INVALID = 0, // This is not an option ID.
    OPT_INPUT,       // Reserved ID for input option.
    OPT_UNKNOWN,     // Reserved ID for unknown option.
#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM, \
               HELPTEXT, METAVAR) OPT_##ID,
#include "clang/Driver/Options.def"
    LastOption
#undef OPTION
  };
}
  
  class Arg;
  class InputArgList;
  class Option;

  /// OptTable - Provide access to the Option info table.
  ///
  /// The OptTable class provides a layer of indirection which allows
  /// Option instance to be created lazily. In the common case, only a
  /// few options will be needed at runtime; the OptTable class
  /// maintains enough information to parse command lines without
  /// instantiating Options, while letting other parts of the driver
  /// still use Option instances where convient.  
  class OptTable {
    /// The table of options which have been constructed, indexed by
    /// option::ID - 1.
    mutable Option **Options;

    /// The index of the first option which can be parsed (i.e., is
    /// not a special option like 'input' or 'unknown', and is not an
    /// option group).
    unsigned FirstSearchableOption;

    Option *constructOption(options::ID id) const;

  public:
    OptTable();
    ~OptTable();

    unsigned getNumOptions() const;

    const char *getOptionName(options::ID id) const;

    /// getOption - Get the given \arg id's Option instance, lazily
    /// creating it if necessary.
    const Option *getOption(options::ID id) const;

    /// getOptionKind - Get the kind of the given option.
    unsigned getOptionKind(options::ID id) const;

    /// getOptionHelpText - Get the help text to use to describe this
    /// option.
    const char *getOptionHelpText(options::ID id) const;

    /// getOptionMetaVar - Get the meta-variable name to use when
    /// describing this options values in the help text.
    const char *getOptionMetaVar(options::ID id) const;

    /// parseOneArg - Parse a single argument; returning the new
    /// argument and updating Index.
    ///
    /// \param [in] [out] Index - The current parsing position in the
    /// argument string list; on return this will be the index of the
    /// next argument string to parse.
    ///
    /// \return - The parsed argument, or 0 if the argument is missing
    /// values (in which case Index still points at the conceptual
    /// next argument string to parse).
    Arg *ParseOneArg(const InputArgList &Args, unsigned &Index) const;
  };
}
}

#endif
OpenPOWER on IntegriCloud