Options.h revision e1495eced887466e235f6a034953adf5ee1e14e6
1//===--- Options.h - Option info & table ------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef CLANG_DRIVER_OPTIONS_H_
11#define CLANG_DRIVER_OPTIONS_H_
12
13namespace clang {
14namespace driver {
15namespace options {
16  enum ID {
17    NotOption = 0, // This is not an option ID.
18    InputOpt,      // Reserved ID for input option.
19    UnknownOpt,    // Reserved ID for unknown option.
20#define OPTION(NAME, ID, KIND, GROUP, ALIAS, FLAGS, PARAM) ID,
21#include "clang/Driver/Options.def"
22    LastOption
23#undef OPTION
24  };
25}
26
27  class Arg;
28  class ArgList;
29  class Option;
30
31  /// OptTable - Provide access to the Option info table.
32  ///
33  /// The OptTable class provides a layer of indirection which allows
34  /// Option instance to be created lazily. In the common case, only a
35  /// few options will be needed at runtime; the OptTable class
36  /// maintains enough information to parse command lines without
37  /// instantiating Options, while letting other parts of the driver
38  /// still use Option instances where convient.
39  class OptTable {
40    mutable Option **Options;
41
42    Option *constructOption(options::ID id) const;
43
44  public:
45    OptTable();
46    ~OptTable();
47
48    unsigned getNumOptions() const;
49
50    const char *getOptionName(options::ID id) const;
51
52    /// getOption - Get the given \arg id's Option instance, lazily
53    /// creating it if necessary.
54    const Option *getOption(options::ID id) const;
55
56    /// parseOneArg - Parse a single argument; returning the new
57    /// argument and updating Index.
58    ///
59    /// \param [in] [out] Index - The current parsing position in the
60    /// argument string list; on return this will be the index of the
61    /// next option to parse.
62    ///
63    /// \param IndexEnd - The last argument string index to consider
64    /// when parsing.
65    Arg *ParseOneArg(const ArgList &Args, unsigned &Index,
66                     unsigned IndexEnd) const;
67  };
68}
69}
70
71#endif
72