14#ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
15#define LLVM_CLANG_BASIC_LANGOPTIONS_H
25#include "llvm/ADT/FloatingPointMode.h"
26#include "llvm/ADT/StringRef.h"
27#include "llvm/BinaryFormat/DXContainer.h"
28#include "llvm/Support/AllocToken.h"
29#include "llvm/TargetParser/Triple.h"
210#define ABI_VER_MAJOR_MINOR(Major, Minor) Ver##Major##_##Minor,
211#define ABI_VER_MAJOR(Major) Ver##Major,
212#define ABI_VER_LATEST(Latest) Latest
213#include "clang/Basic/ABIVersions.def"
455#define LANGOPT(Name, Bits, Default, Compatibility, Description) \
456 unsigned Name : Bits;
457#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description)
458#include "clang/Basic/LangOptions.def"
463#define LANGOPT(Name, Bits, Default, Compatibility, Description)
464#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
465 LLVM_PREFERRED_TYPE(Type) \
466 unsigned Name : Bits;
467#include "clang/Basic/LangOptions.def"
568 std::optional<TargetCXXABI::Kind>
CXXABI;
634 std::vector<std::string> &Includes,
638#define LANGOPT(Name, Bits, Default, Compatibility, Description)
639#define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description) \
640 Type get##Name() const { return static_cast<Type>(Name); } \
641 void set##Name(Type Value) { \
642 assert(static_cast<unsigned>(Value) < (1u << Bits)); \
643 Name = static_cast<unsigned>(Value); \
645#include "clang/Basic/LangOptions.def"
649 return getCompilingModule() !=
CMK_None;
667 return ObjCRuntime.isSubscriptPointerArithmetic() &&
668 !ObjCSubscriptingLegacyRuntime;
674 return MSCompatibilityVersion >= MajorVersion * 100000U;
695 return ObjCAutoRefCount || ObjCWeak;
699 return ConvergentFunctions;
733 bool hasAtExit()
const {
return !(OpenMP && OpenMPIsTargetDevice); }
756 bool isSYCL()
const {
return SYCLIsDevice || SYCLIsHost; }
759 return getDefaultVisibilityExportMapping() !=
764 return getDefaultVisibilityExportMapping() ==
769 return getDefaultVisibilityExportMapping() ==
774 return getGlobalAllocationFunctionVisibility() !=
779 return getGlobalAllocationFunctionVisibility() ==
784 return getGlobalAllocationFunctionVisibility() ==
789 return getGlobalAllocationFunctionVisibility() ==
799 return RoundingMath ? RoundingMode::Dynamic
800 : RoundingMode::NearestTiesToEven;
812 return OpenMPIsTargetDevice || CUDAIsDevice || SYCLIsDevice;
826class FPOptionsOverride;
839#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
840 static constexpr storage_type NAME##Shift = \
841 PREVIOUS##Shift + PREVIOUS##Width; \
842 static constexpr storage_type NAME##Width = WIDTH; \
843 static constexpr storage_type NAME##Mask = ((1 << NAME##Width) - 1) \
845#include "clang/Basic/FPOptions.def"
848#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
849#include "clang/Basic/FPOptions.def"
861 setConstRoundingMode(RoundingMode::Dynamic);
869 auto LangOptContractMode = LO.getDefaultFPContractMode();
872 setFPContractMode(LangOptContractMode);
873 setRoundingMath(LO.RoundingMath);
874 setConstRoundingMode(LangOptions::RoundingMode::Dynamic);
875 setSpecifiedExceptionMode(LO.getFPExceptionMode());
876 setAllowFPReassociate(LO.AllowFPReassoc);
877 setNoHonorNaNs(LO.NoHonorNaNs);
878 setNoHonorInfs(LO.NoHonorInfs);
879 setNoSignedZero(LO.NoSignedZero);
880 setAllowReciprocal(LO.AllowRecip);
881 setAllowApproxFunc(LO.ApproxFunc);
887 setAllowFEnvAccess(
true);
890 setComplexRange(LO.getComplexRange());
910 getAllowFEnvAccess();
915 if (RM == RoundingMode::Dynamic) {
919 if (!getAllowFEnvAccess() && !getRoundingMath())
920 RM = RoundingMode::NearestTiesToEven;
928 if (getAllowFEnvAccess())
957#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
958 TYPE get##NAME() const { \
959 return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift); \
961 void set##NAME(TYPE value) { \
962 assert(storage_type(value) < (1u << WIDTH)); \
963 Value = (Value & ~NAME##Mask) | (storage_type(value) << NAME##Shift); \
965#include "clang/Basic/FPOptions.def"
966 LLVM_DUMP_METHOD
void dump();
993 "Too short type for FPOptionsOverride");
1006 : Options(FPO), OverrideMask(Mask) {}
1023 setAllowFPReassociateOverride(!
Value);
1024 setNoHonorNaNsOverride(!
Value);
1025 setNoHonorInfsOverride(!
Value);
1026 setNoSignedZeroOverride(!
Value);
1027 setAllowReciprocalOverride(!
Value);
1028 setAllowApproxFuncOverride(!
Value);
1029 setMathErrnoOverride(
Value);
1041 return (
static_cast<storage_type>(Options.getAsOpaqueInt())
1055 (Options.getAsOpaqueInt() & OverrideMask));
1064 return Options == other.Options && OverrideMask == other.OverrideMask;
1068#define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
1069 bool has##NAME##Override() const { \
1070 return OverrideMask & FPOptions::NAME##Mask; \
1072 TYPE get##NAME##Override() const { \
1073 assert(has##NAME##Override()); \
1074 return Options.get##NAME(); \
1076 void clear##NAME##Override() { \
1079 Options.set##NAME(TYPE(0)); \
1080 OverrideMask &= ~FPOptions::NAME##Mask; \
1082 void set##NAME##Override(TYPE value) { \
1083 Options.set##NAME(value); \
1084 OverrideMask |= FPOptions::NAME##Mask; \
1086#include "clang/Basic/FPOptions.def"
1087 LLVM_DUMP_METHOD
void dump();
1091 if (Value ==
Base.Value)
1093 return getChangesSlow(
Base);
1135 llvm_unreachable(
"Invalid AtomicOptionKind");
1150 llvm_unreachable(
"Invalid AtomicOptionKind");
1153 LLVM_DUMP_METHOD
void dump()
const {
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines types useful for describing an Objective-C runtime.
Defines the clang::SanitizerKind enum.
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.
Defines the clang::Visibility enumeration and various utility functions.
Represents difference between two FPOptions values.
void setAllowFPContractAcrossStatement()
static FPOptionsOverride getFromOpaqueInt(storage_type I)
bool operator!=(FPOptionsOverride other) const
FPOptionsOverride(FPOptions FPO)
LLVM_DUMP_METHOD void dump()
void setFPPreciseEnabled(bool Value)
void setAllowFPContractWithinStatement()
FPOptionsOverride(FPOptions FPO, FPOptions::storage_type Mask)
FPOptions applyOverrides(FPOptions Base)
bool operator==(FPOptionsOverride other) const
void setDisallowFPContract()
llvm::RoundingMode RoundingMode
static constexpr storage_type OverrideMaskBits
Bit mask selecting bits of OverrideMask in serialized representation of FPOptionsOverride.
storage_type getAsOpaqueInt() const
void setDisallowOptimizations()
FPOptions applyOverrides(const LangOptions &LO)
uint64_t storage_type
The type suitable for storing values of FPOptionsOverride.
FPOptionsOverride(const LangOptions &LO)
bool requiresTrailingStorage() const
void applyChanges(FPOptionsOverride FPO)
bool isFPConstrained() const
static constexpr storage_type FirstShift
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
storage_type getAsOpaqueInt() const
static constexpr storage_type TotalWidth
LangOptions::FPExceptionModeKind getExceptionMode() const
FPOptions(const LangOptions &LO)
static constexpr storage_type FirstWidth
void setAllowFPContractWithinStatement()
static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO)
Return the default value of FPOptions that's used when trailing storage isn't required.
static FPOptions getFromOpaqueInt(storage_type Value)
bool allowFPContractAcrossStatement() const
bool operator==(FPOptions other) const
bool allowFPContractWithinStatement() const
LLVM_DUMP_METHOD void dump()
void setAllowFPContractAcrossStatement()
static constexpr unsigned StorageBitSize
llvm::RoundingMode RoundingMode
RoundingMode getRoundingMode() const
Bitfields of LangOptions, split out from LangOptions in order to ensure that this large collection of...
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_Extended
Use extended type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
@ FEM_Source
Use the declared type for fp arithmetic.
SignReturnAddressScopeKind
@ None
No signing for any function.
@ NonLeaf
Sign the return address of functions that spill LR.
@ All
Sign the return address of all functions,.
@ CMK_None
Not compiling a module interface at all.
@ CMK_HeaderUnit
Compiling a module header unit.
@ CMK_ModuleMap
Compiling a module from a module map.
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
ComplexRangeKind
Controls the various implementations for complex multiplication and.
@ CX_Full
Implementation of complex division and multiplication using a call to runtime library functions(gener...
@ CX_Basic
Implementation of complex division and multiplication using algebraic formulas at source precision.
@ CX_Promoted
Implementation of complex division using algebraic formulas at higher precision.
@ CX_None
No range rule is enabled.
@ CX_Improved
Implementation of complex division offering an improved handling for overflow in intermediate calcula...
@ Swift5_0
Interoperability with the Swift 5.0 runtime.
@ ObjectiveC
Interoperability with the ObjectiveC runtime.
@ Standalone
CoreFoundation does not have any language interoperability.
@ Unspecified
No interoperability ABI has been specified.
@ Swift
Interoperability with the latest known version of the Swift runtime.
@ Swift4_2
Interoperability with the Swift 4.2 runtime.
@ Swift4_1
Interoperability with the Swift 4.1 runtime.
llvm::RoundingMode RoundingMode
clang::MSVtorDispMode MSVtorDispMode
@ Legacy
Legacy default stream.
@ PerThread
Per-thread default stream.
@ ForceProtected
Force protected visibility.
@ ForceDefault
Force default visibility.
@ ForceHidden
Force hidden visibility.
@ Source
Don't alter the visibility.
@ BKey
Return address signing uses APIB key.
@ AKey
Return address signing uses APIA key.
@ ExtendTo32
Integer arguments are sign or zero extended to 32/64 bits during default argument promotions.
@ Single
Single Threaded Environment.
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
StrictFlexArraysLevelKind
@ ZeroOrIncomplete
Any trailing array member of undefined or 0 size is a FAM.
@ OneZeroOrIncomplete
Any trailing array member of undefined, 0, or 1 size is a FAM.
@ IncompleteOnly
Any trailing array member of undefined size is a FAM.
@ Microsoft
Use Microsoft C++ ABI rules for bit-field layout and fundamental types alignment.
@ Itanium
Use Itanium rules for bit-field layout and fundamental types alignment.
friend class CompilerInvocationBase
PragmaMSPointersToMembersKind
@ PPTMK_FullGeneralityMultipleInheritance
@ PPTMK_FullGeneralityVirtualInheritance
@ PPTMK_FullGeneralitySingleInheritance
OverflowPatternExclusionKind
Exclude certain code patterns from being instrumented by arithmetic overflow sanitizers.
@ None
Don't exclude any overflow patterns from sanitizers.
@ AddUnsignedOverflowTest
if (a + b < a)
@ All
Exclude all overflow patterns (below)
@ AddSignedOverflowTest
if (a + b < a)
@ PostDecrInWhile
while (count–)
clang::Visibility Visibility
DefaultVisiblityExportMapping
@ Explicit
map only explicit default visibilities to exported
@ All
map all default visibilities to exported
CompatibilityKind
For ASTs produced with different option value, signifies their level of compatibility.
@ NotCompatible
Does affect the construction of the AST in a way that does prevent module interoperability.
@ Compatible
Does affect the construction of the AST in a way that doesn't prevent interoperability (that is,...
@ Benign
Does not affect the construction of the AST in any way (that is, the value can be different between a...
FPExceptionModeKind
Possible floating point exception behavior.
@ FPE_Default
Used internally to represent initial unspecified value.
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
@ FPE_MayTrap
Transformations do not cause new exceptions but may hide some.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
clang::CFBranchLabelSchemeKind CFBranchLabelSchemeKind
friend class CompilerInvocation
VisibilityFromDLLStorageClassKinds
@ Keep
Keep the IR-gen assigned visibility.
@ Protected
Override the IR-gen assigned visibility with protected visibility.
@ Hidden
Override the IR-gen assigned visibility with hidden visibility.
ClangABI
Clang versions with different platform ABI conformance.
RegisterStaticDestructorsKind
Controls which variables have static destructors registered.
@ ThreadLocal
Register static destructors only for thread-local variables.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SanitizerSet UBSanFeatureIgnoredSanitize
Set of (UBSan) sanitizers that when enabled do not cause __has_feature(undefined_behavior_sanitizer) ...
bool isSignReturnAddressWithAKey() const
Check if return address signing uses AKey.
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
std::vector< std::string > OverflowPatternExclusionValues
std::optional< TargetCXXABI::Kind > CXXABI
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
bool AtomicFineGrainedMemory
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
std::string ModuleName
The module currently being compiled as specified by -fmodule-name.
std::vector< std::string > XRayNeverInstrumentFiles
Paths to the XRay "never instrument" files specifying which objects (files, functions,...
FPExceptionModeKind getDefaultExceptionMode() const
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
bool isImplicitIntAllowed() const
Returns true if implicit int is supported at all.
bool isCompilingModuleImplementation() const
Are we compiling a module implementation?
bool isNoBuiltinFunc(StringRef Name) const
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* optio...
clang::ObjCRuntime ObjCRuntime
CoreFoundationABI CFRuntime
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
unsigned OverflowPatternExclusionMask
Which overflow patterns should be excluded from sanitizer instrumentation.
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
bool hasDefaultVisibilityExportMapping() const
SanitizerSet Sanitize
Set of enabled sanitizers.
std::optional< llvm::AllocTokenMode > AllocTokenMode
The allocation token mode.
CommentOptions CommentOpts
Options for parsing comments.
bool isExplicitDefaultVisibilityExportMapping() const
std::vector< std::string > XRayAlwaysInstrumentFiles
Paths to the XRay "always instrument" files specifying which objects (files, functions,...
bool hasAtExit() const
Returns true if the language supports calling the 'atexit' function.
bool trackLocalOwningModule() const
Do we need to track the owning module for a local declaration?
bool isAllDefaultVisibilityExportMapping() const
bool isSubscriptPointerArithmetic() const
bool UseTargetPathSeparator
Indicates whether to use target's platform-specific file separator when FILE macro is used and when c...
std::string ObjCConstantIntegerNumberClass
bool isSignedOverflowDefined() const
bool hasDefaultGlobalAllocationFunctionVisibility() const
bool AtomicIgnoreDenormalMode
bool hasGlobalAllocationFunctionVisibility() const
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
std::string ObjCConstantDoubleNumberClass
bool implicitFunctionsAllowed() const
Returns true if implicit function declarations are allowed in the current language mode.
bool hasSignReturnAddress() const
Check if return address signing is enabled.
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...
bool isCompatibleWithMSVC() const
bool assumeFunctionsAreConvergent() const
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
bool allowsNonTrivialObjCLifetimeQualifiers() const
True if any ObjC types may have non-trivial lifetime qualifiers.
bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const
bool allowArrayReturnTypes() const
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
std::string HLSLRootSigOverride
The HLSL root signature that will be used to overide the root signature used for the shader entry poi...
bool hasHiddenGlobalAllocationFunctionVisibility() const
std::string RandstructSeed
The seed used by the randomize structure layout feature.
std::map< std::string, std::string, std::greater< std::string > > MacroPrefixMap
A prefix map for FILE, BASE_FILE and __builtin_FILE().
std::vector< std::string > ProfileListFiles
Paths to special case list files specifying which entities (files, functions) should or should not be...
void remapPathPrefix(SmallVectorImpl< char > &Path) const
Remap path prefix according to -fmacro-prefix-path option.
bool isTargetDevice() const
True when compiling for an offloading target device.
std::optional< uint64_t > AllocTokenMax
Maximum number of allocation tokens (0 = target SIZE_MAX), nullopt if none set (use target SIZE_MAX).
bool hasProtectedGlobalAllocationFunctionVisibility() const
std::optional< uint32_t > getCPlusPlusLangStd() const
Returns the most applicable C++ standard-compliant language version code.
LangStandard::Kind LangStd
The used language standard.
llvm::dxbc::RootSignatureVersion HLSLRootSigVer
The HLSL root signature version for dxil.
std::optional< uint32_t > getCLangStd() const
Returns the most applicable C standard-compliant language version code.
RoundingMode getDefaultRoundingMode() const
bool isCompilingModule() const
Are we compiling a module?
bool isImplicitIntRequired() const
Returns true if implicit int is part of the language requirements.
bool isSignReturnAddressScopeAll() const
Check if leaf functions are also signed.
std::string ObjCConstantArrayClass
std::string ObjCConstantStringClass
std::string CUID
The user provided compilation unit ID, if non-empty.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
std::string ObjCConstantDictionaryClass
std::string ObjCConstantFloatNumberClass
GPUDefaultStreamKind GPUDefaultStream
The default stream kind used for HIP kernel launching.
bool AtomicRemoteMemory
Atomic code-generation options.
bool threadPrivateMemoryAtomicsAreUndefined() const
Return true if atomicrmw operations targeting allocations in private memory are undefined.
std::vector< std::string > XRayAttrListFiles
Paths to the XRay attribute list files, specifying which objects (files, functions,...
bool SanitizeCoverage
Is at least one coverage instrumentation type enabled.
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
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.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
The basic abstraction for the target Objective-C runtime.
The JSON file list parser is used to communicate input to InstallAPI.
Language
The language for the input, used to select and validate the language standard and possible actions.
@ Result
The result type of a method or function.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
ShaderStage
Shader programs run in specific pipeline stages.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_Incremental
The translation unit is a is a complete translation unit that we might incrementally extend later.
@ TU_Complete
The translation unit is a complete translation unit.
@ TU_ClangModule
The translation unit is a clang module.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
PointerAuthenticationMode
@ LANGOPT_ATOMIC_OPTION_LAST
@ None
The alignment was not explicit in code.
Visibility
Describes the different kinds of visibility that a declaration may have.
unsigned fine_grained_memory
void setOption(AtomicOptionKind Kind, bool Value)
LLVM_DUMP_METHOD void dump() const
unsigned ignore_denormal_mode
bool getOption(AtomicOptionKind Kind) const