clang 22.0.0git
OptionUtils.h
Go to the documentation of this file.
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_OPTIONS_OPTIONUTILS_H
14#define LLVM_CLANG_OPTIONS_OPTIONUTILS_H
15
17#include "clang/Basic/LLVM.h"
18#include "llvm/Option/OptSpecifier.h"
19
20namespace llvm {
21
22namespace opt {
23
24class ArgList;
25
26} // namespace opt
27
28} // namespace llvm
29
30namespace clang {
31
32/// Return the value of the last argument as an integer, or a default. If Diags
33/// is non-null, emits an error if the argument is given, but non-integral.
34int getLastArgIntValue(const llvm::opt::ArgList &Args,
35 llvm::opt::OptSpecifier Id, int Default,
36 DiagnosticsEngine *Diags = nullptr, unsigned Base = 0);
37
38inline int getLastArgIntValue(const llvm::opt::ArgList &Args,
39 llvm::opt::OptSpecifier Id, int Default,
40 DiagnosticsEngine &Diags, unsigned Base = 0) {
41 return getLastArgIntValue(Args, Id, Default, &Diags, Base);
42}
43
44uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
45 llvm::opt::OptSpecifier Id, uint64_t Default,
46 DiagnosticsEngine *Diags = nullptr,
47 unsigned Base = 0);
48
49inline uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args,
50 llvm::opt::OptSpecifier Id,
51 uint64_t Default,
52 DiagnosticsEngine &Diags,
53 unsigned Base = 0) {
54 return getLastArgUInt64Value(Args, Id, Default, &Diags, Base);
55}
56
57// Parse -mprefer-vector-width=. Return the Value string if well-formed.
58// Otherwise, return an empty string and issue a diagnosic message if needed.
60 const llvm::opt::ArgList &Args);
61
62// Parse -mrecip. Return the Value string if well-formed.
63// Otherwise, return an empty string and issue a diagnosic message if needed.
65 const llvm::opt::ArgList &Args);
66
67/// Get the directory where the compiler headers reside, relative to the
68/// compiler binary path \p BinaryPath.
69std::string GetResourcesPath(StringRef BinaryPath);
70
71/// Get the directory where the compiler headers reside, relative to the
72/// compiler binary path (found by the passed in arguments).
73///
74/// \param Argv0 The program path (from argv[0]), for finding the builtin
75/// compiler path.
76/// \param MainAddr The address of main (or some other function in the main
77/// executable), for finding the builtin compiler path.
78std::string GetResourcesPath(const char *Argv0, void *MainAddr);
79
80} // namespace clang
81
82#endif // LLVM_CLANG_OPTIONS_OPTIONUTILS_H
Defines the Diagnostic-related interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:232
The JSON file list parser is used to communicate input to InstallAPI.
StringRef parseMPreferVectorWidthOption(clang::DiagnosticsEngine &Diags, const llvm::opt::ArgList &Args)
uint64_t getLastArgUInt64Value(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, uint64_t Default, DiagnosticsEngine *Diags=nullptr, unsigned Base=0)
std::string GetResourcesPath(StringRef BinaryPath)
Get the directory where the compiler headers reside, relative to the compiler binary path BinaryPath.
int getLastArgIntValue(const llvm::opt::ArgList &Args, llvm::opt::OptSpecifier Id, int Default, DiagnosticsEngine *Diags=nullptr, unsigned Base=0)
Return the value of the last argument as an integer, or a default.
StringRef parseMRecipOption(clang::DiagnosticsEngine &Diags, const llvm::opt::ArgList &Args)
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30