15#include "llvm/Support/Path.h"
20#define LANGOPT(Name, Bits, Default, Compatibility, Description) Name = Default;
21#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
23#include "clang/Basic/LangOptions.def"
27#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
28 if constexpr (CompatibilityKind::Compatibility == CompatibilityKind::Benign) \
30#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
31 if constexpr (CompatibilityKind::Compatibility == CompatibilityKind::Benign) \
32 Name = static_cast<unsigned>(Default);
33#include "clang/Basic/LangOptions.def"
39 AllowFPReassoc = UnsafeFPMath;
40 NoHonorInfs = FastMath;
41 NoHonorNaNs = FastMath;
60 const int Ver = OpenCLCPlusPlus ? OpenCLCPlusPlusVersion : OpenCLVersion;
61 if (OpenCLCPlusPlus && Ver != 100)
62 return VersionTuple(Ver / 100);
63 return VersionTuple(Ver / 100, (Ver % 100) / 10);
69 if (OpenCLCPlusPlusVersion == 100)
71 if (OpenCLCPlusPlusVersion == 202100)
73 llvm_unreachable(
"Unknown OpenCL version");
78 if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second))
85 llvm::raw_string_ostream Out(
Result);
86 Out << (OpenCLCPlusPlus ?
"C++ for OpenCL" :
"OpenCL C") <<
" version "
93 const llvm::Triple &T,
94 std::vector<std::string> &Includes,
104 Opts.AsmPreprocessor = 1;
114 Opts.C99 = Std.
isC99();
115 Opts.C11 = Std.
isC11();
116 Opts.C17 = Std.
isC17();
117 Opts.C23 = Std.
isC23();
118 Opts.C2y = Std.
isC2y();
127 Opts.GNUCVersion = 0;
133 Opts.NamedLoops = Std.
isC2y();
137 if (Opts.IncludeDefaultHeader)
138 Includes.push_back(
"hlsl.h");
140 Opts.MaxMatrixDimension = 4;
145 if (
LangStd == LangStandard::lang_opencl10)
146 Opts.OpenCLVersion = 100;
147 else if (
LangStd == LangStandard::lang_opencl11)
148 Opts.OpenCLVersion = 110;
149 else if (
LangStd == LangStandard::lang_opencl12)
150 Opts.OpenCLVersion = 120;
151 else if (
LangStd == LangStandard::lang_opencl20)
152 Opts.OpenCLVersion = 200;
153 else if (
LangStd == LangStandard::lang_opencl30)
154 Opts.OpenCLVersion = 300;
155 else if (
LangStd == LangStandard::lang_openclcpp10)
156 Opts.OpenCLCPlusPlusVersion = 100;
157 else if (
LangStd == LangStandard::lang_openclcpp2021)
158 Opts.OpenCLCPlusPlusVersion = 202100;
159 else if (
LangStd == LangStandard::lang_hlsl2015)
161 else if (
LangStd == LangStandard::lang_hlsl2016)
163 else if (
LangStd == LangStandard::lang_hlsl2017)
165 else if (
LangStd == LangStandard::lang_hlsl2018)
167 else if (
LangStd == LangStandard::lang_hlsl2021)
169 else if (
LangStd == LangStandard::lang_hlsl202x)
171 else if (
LangStd == LangStandard::lang_hlsl202y)
179 Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
184 if (Opts.IncludeDefaultHeader) {
185 if (Opts.DeclareOpenCLBuiltins) {
187 Includes.push_back(
"opencl-c-base.h");
189 Includes.push_back(
"opencl-c.h");
206 }
else if (Opts.CUDA) {
209 Opts.OpenCLVersion = 200;
216 Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C23;
219 Opts.Half = Opts.OpenCL || Opts.HLSL;
221 Opts.PreserveVec3Type = Opts.HLSL;
231#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
232 if (get##NAME() != Base.get##NAME()) \
233 OverrideMask |= NAME##Mask;
234#include "clang/Basic/FPOptions.def"
239#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
240 llvm::errs() << "\n " #NAME " " << get##NAME();
241#include "clang/Basic/FPOptions.def"
242 llvm::errs() <<
"\n";
246#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
247 if (has##NAME##Override()) \
248 llvm::errs() << "\n " #NAME " Override is " << get##NAME##Override();
249#include "clang/Basic/FPOptions.def"
250 llvm::errs() <<
"\n";
259 Std = LangStandard::lang_cxx26;
261 Std = LangStandard::lang_cxx23;
263 Std = LangStandard::lang_cxx20;
265 Std = LangStandard::lang_cxx17;
267 Std = LangStandard::lang_cxx14;
269 Std = LangStandard::lang_cxx11;
271 Std = LangStandard::lang_cxx98;
279 Std = LangStandard::lang_c2y;
281 Std = LangStandard::lang_c23;
283 Std = LangStandard::lang_c17;
285 Std = LangStandard::lang_c11;
287 Std = LangStandard::lang_c99;
289 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.