OptionUtils.h 2.3 KB

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