15#include "clang/Config/config.h"
16#include "llvm/Support/Path.h"
21#define LANGOPT(Name, Bits, Default, Compatibility, Description) Name = Default;
22#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
24#include "clang/Basic/LangOptions.def"
28#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
29 if constexpr (CompatibilityKind::Compatibility == CompatibilityKind::Benign) \
31#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
32 if constexpr (CompatibilityKind::Compatibility == CompatibilityKind::Benign) \
33 Name = static_cast<unsigned>(Default);
34#include "clang/Basic/LangOptions.def"
40 AllowFPReassoc = UnsafeFPMath;
41 NoHonorInfs = FastMath;
42 NoHonorNaNs = FastMath;
61 const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
62 if (OpenCLCPlusPlus && Ver != 100)
63 return VersionTuple(Ver / 100);
64 return VersionTuple(Ver / 100, (Ver % 100) / 10);
70 if (OpenCLCPlusPlusVersion == 100)
72 if (OpenCLCPlusPlusVersion == 202100)
74 llvm_unreachable(
"Unknown OpenCL version");
79 if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
86 llvm::raw_string_ostream Out(
Result);
87 Out << (OpenCLCPlusPlus ?
"C++ for OpenCL" :
"OpenCL C") <<
" version "
94 const llvm::Triple &T,
95 std::vector<std::string> &Includes,
105 Opts.AsmPreprocessor = 1;
115 Opts.C99 = Std.
isC99();
116 Opts.C11 = Std.
isC11();
117 Opts.C17 = Std.
isC17();
118 Opts.C23 = Std.
isC23();
119 Opts.C2y = Std.
isC2y();
128 Opts.GNUCVersion = 0;
134 Opts.NamedLoops = Std.
isC2y();
138 if (Opts.IncludeDefaultHeader)
139 Includes.push_back(
"hlsl.h");
141 Opts.MaxMatrixDimension = 4;
146 if (
LangStd == LangStandard::lang_opencl10)
147 Opts.OpenCLVersion = 100;
148 else if (
LangStd == LangStandard::lang_opencl11)
149 Opts.OpenCLVersion = 110;
150 else if (
LangStd == LangStandard::lang_opencl12)
151 Opts.OpenCLVersion = 120;
152 else if (
LangStd == LangStandard::lang_opencl20)
153 Opts.OpenCLVersion = 200;
154 else if (
LangStd == LangStandard::lang_opencl30)
155 Opts.OpenCLVersion = 300;
156 else if (
LangStd == LangStandard::lang_openclcpp10)
157 Opts.OpenCLCPlusPlusVersion = 100;
158 else if (
LangStd == LangStandard::lang_openclcpp2021)
159 Opts.OpenCLCPlusPlusVersion = 202100;
160 else if (
LangStd == LangStandard::lang_hlsl2015)
162 else if (
LangStd == LangStandard::lang_hlsl2016)
164 else if (
LangStd == LangStandard::lang_hlsl2017)
166 else if (
LangStd == LangStandard::lang_hlsl2018)
168 else if (
LangStd == LangStandard::lang_hlsl2021)
170 else if (
LangStd == LangStandard::lang_hlsl202x)
172 else if (
LangStd == LangStandard::lang_hlsl202y)
180 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
185 if (Opts.IncludeDefaultHeader) {
186 if (Opts.DeclareOpenCLBuiltins) {
188 Includes.push_back(
"opencl-c-base.h");
190 Includes.push_back(
"opencl-c.h");
207 }
else if (Opts.CUDA) {
210 Opts.OpenCLVersion = 200;
217 Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C23;
220 Opts.Half = Opts.OpenCL || Opts.HLSL;
222 Opts.PreserveVec3Type = Opts.HLSL;
232#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
233 if (get##NAME() != Base.get##NAME()) \
234 OverrideMask |= NAME##Mask;
235#include "clang/Basic/FPOptions.def"
240#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
241 llvm::errs() << "\n " #NAME " " << get##NAME();
242#include "clang/Basic/FPOptions.def"
243 llvm::errs() <<
"\n";
247#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
248 if (has##NAME##Override()) \
249 llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
250#include "clang/Basic/FPOptions.def"
251 llvm::errs() <<
"\n";
260 Std = LangStandard::lang_cxx26;
262 Std = LangStandard::lang_cxx23;
264 Std = LangStandard::lang_cxx20;
266 Std = LangStandard::lang_cxx17;
268 Std = LangStandard::lang_cxx14;
270 Std = LangStandard::lang_cxx11;
272 Std = LangStandard::lang_cxx98;
280 Std = LangStandard::lang_c2y;
282 Std = LangStandard::lang_c23;
284 Std = LangStandard::lang_c17;
286 Std = LangStandard::lang_c11;
288 Std = LangStandard::lang_c99;
290 Std = LangStandard::lang_c94;
Defines the clang::LangOptions interface.
Represents difference between two FPOptions values.
LLVM_DUMP_METHOD void dump()
static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO)
Return the default value of FPOptions that's used when trailing storage isn't required.
LLVM_DUMP_METHOD void dump()
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
std::vector< std::string > XRayNeverInstrumentFiles
Paths to the XRay "never instrument" files specifying which objects (files, functions,...
bool isNoBuiltinFunc(StringRef Name) const
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* optio...
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
std::vector< std::string > XRayAlwaysInstrumentFiles
Paths to the XRay "always instrument" files specifying which objects (files, functions,...
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
static void setLangDefaults(LangOptions &Opts, Language Lang, const llvm::Triple &T, std::vector< std::string > &Includes, LangStandard::Kind LangStd=LangStandard::lang_unspecified)
Set language defaults for the given input language and language standard in the given LangOptions obj...
std::map< std::string, std::string, std::greater< std::string > > MacroPrefixMap
A prefix map for FILE, BASE_FILE and __builtin_FILE().
void remapPathPrefix(SmallVectorImpl< char > &Path) const
Remap path prefix according to -fmacro-prefix-path option.
std::optional< uint32_t > getCPlusPlusLangStd() const
Returns the most applicable C++ standard-compliant language version code.
LangStandard::Kind LangStd
The used language standard.
std::optional< uint32_t > getCLangStd() const
Returns the most applicable C standard-compliant language version code.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
std::vector< std::string > NoSanitizeFiles
Paths to files specifying which objects (files, functions, variables) should not be instrumented.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
The JSON file list parser is used to communicate input to InstallAPI.
LangStandard::Kind getDefaultLanguageStandard(clang::Language Lang, const llvm::Triple &T)
Language
The language for the input, used to select and validate the language standard and possible actions.
@ Asm
Assembly: we accept this only so that we can preprocess it.
@ Result
The result type of a method or function.
LangStandard - Information about the properties of a particular language standard.
bool isCPlusPlus20() const
isCPlusPlus20 - Language is a C++20 variant (or later).
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
bool hasRawStringLiterals() const
hasRawStringLiterals - Language supports R"()" raw string literals.
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
bool isC11() const
isC11 - Language is a superset of C11.
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
bool isC17() const
isC17 - Language is a superset of C17.
bool isCPlusPlus26() const
isCPlusPlus26 - Language is a post-C++26 variant (or later).
bool isC2y() const
isC2y - Language is a superset of C2y.
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
std::optional< uint32_t > getVersion() const
Get the version code for this language standard.
bool isC23() const
isC23 - Language is a superset of C23.
static const LangStandard & getLangStandardForKind(Kind K)
bool isOpenCL() const
isOpenCL - Language is a OpenCL variant.
bool hasLineComments() const
Language supports '//' comments.
bool allowLiteralDigitSeparator() const
allowLiteralDigitSeparator - Language supports literal digit seperator
bool isCPlusPlus23() const
isCPlusPlus23 - Language is a post-C++23 variant (or later).
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
bool isC99() const
isC99 - Language is a superset of C99.