1 //===- OptionUtils.h - Utilities for command line arguments -----*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This header contains utilities for command line arguments.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_DRIVER_OPTIONUTILS_H
14 #define LLVM_CLANG_DRIVER_OPTIONUTILS_H
16 #include "clang/Basic/Diagnostic.h"
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/Option/OptSpecifier.h"
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);
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);
43 uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
44 llvm::opt::OptSpecifier Id, uint64_t Default,
45 DiagnosticsEngine *Diags = nullptr,
48 inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
49 llvm::opt::OptSpecifier Id,
51 DiagnosticsEngine &Diags,
53 return getLastArgUInt64Value(Args, Id, Default, &Diags, Base);
58 #endif // LLVM_CLANG_DRIVER_OPTIONUTILS_H