Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 14 | pmbaty | 1 | //===- OptionUtils.h - Utilities for command line arguments -----*- C++ -*-===// | 
| 2 | // | ||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| 4 | // See https://llvm.org/LICENSE.txt for license information. | ||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| 6 | // | ||
| 7 | //===----------------------------------------------------------------------===// | ||
| 8 | // | ||
| 9 | //  This header contains utilities for command line arguments. | ||
| 10 | // | ||
| 11 | //===----------------------------------------------------------------------===// | ||
| 12 | |||
| 13 | #ifndef LLVM_CLANG_DRIVER_OPTIONUTILS_H | ||
| 14 | #define LLVM_CLANG_DRIVER_OPTIONUTILS_H | ||
| 15 | |||
| 16 | #include "clang/Basic/Diagnostic.h" | ||
| 17 | #include "clang/Basic/LLVM.h" | ||
| 18 | #include "llvm/Option/OptSpecifier.h" | ||
| 19 | |||
| 20 | namespace llvm { | ||
| 21 | |||
| 22 | namespace opt { | ||
| 23 | |||
| 24 | class ArgList; | ||
| 25 | |||
| 26 | } // namespace opt | ||
| 27 | |||
| 28 | } // namespace llvm | ||
| 29 | |||
| 30 | namespace clang { | ||
| 31 | /// Return the value of the last argument as an integer, or a default. If Diags | ||
| 32 | /// is non-null, emits an error if the argument is given, but non-integral. | ||
| 33 | int getLastArgIntValue(const llvm::opt::ArgList &Args, | ||
| 34 | llvm::opt::OptSpecifier Id, int Default, | ||
| 35 | DiagnosticsEngine *Diags = nullptr, unsigned Base = 0); | ||
| 36 | |||
| 37 | inline int getLastArgIntValue(const llvm::opt::ArgList &Args, | ||
| 38 | llvm::opt::OptSpecifier Id, int Default, | ||
| 39 | DiagnosticsEngine &Diags, unsigned Base = 0) { | ||
| 40 | return getLastArgIntValue(Args, Id, Default, &Diags, Base); | ||
| 41 | } | ||
| 42 | |||
| 43 | uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, | ||
| 44 | llvm::opt::OptSpecifier Id, uint64_t Default, | ||
| 45 | DiagnosticsEngine *Diags = nullptr, | ||
| 46 | unsigned Base = 0); | ||
| 47 | |||
| 48 | inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, | ||
| 49 | llvm::opt::OptSpecifier Id, | ||
| 50 |                                       uint64_t Default, | ||
| 51 |                                       DiagnosticsEngine &Diags, | ||
| 52 | unsigned Base = 0) { | ||
| 53 | return getLastArgUInt64Value(Args, Id, Default, &Diags, Base); | ||
| 54 | } | ||
| 55 | |||
| 56 | } // namespace clang | ||
| 57 | |||
| 58 | #endif // LLVM_CLANG_DRIVER_OPTIONUTILS_H |