Go to the documentation of this file.
14 #ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
15 #define LLVM_CLANG_BASIC_LANGOPTIONS_H
24 #include "llvm/ADT/FloatingPointMode.h"
25 #include "llvm/ADT/StringRef.h"
26 #include "llvm/ADT/Triple.h"
40 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
41 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
42 #include "clang/Basic/LangOptions.def"
47 #define LANGOPT(Name, Bits, Default, Description)
48 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
50 #include "clang/Basic/LangOptions.def"
470 std::optional<TargetCXXABI::Kind>
CXXABI;
503 std::vector<std::string> &Includes,
507 #define LANGOPT(Name, Bits, Default, Description)
508 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
509 Type get##Name() const { return static_cast<Type>(Name); } \
510 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
511 #include "clang/Basic/LangOptions.def"
515 return getCompilingModule() !=
CMK_None;
539 !ObjCSubscriptingLegacyRuntime;
543 return MSCompatibilityVersion >= MajorVersion * 100000
U;
556 return ObjCAutoRefCount || ObjCWeak;
560 return ConvergentFunctions;
622 bool isSYCL()
const {
return SYCLIsDevice || SYCLIsHost; }
625 return getDefaultVisibilityExportMapping() !=
630 return getDefaultVisibilityExportMapping() ==
635 return getDefaultVisibilityExportMapping() ==
643 return RoundingMath ? RoundingMode::Dynamic
644 : RoundingMode::NearestTiesToEven;
649 if (EM == FPExceptionModeKind::FPE_Default)
650 return FPExceptionModeKind::FPE_Ignore;
656 class FPOptionsOverride;
669 #define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
670 static constexpr storage_type NAME##Shift = \
671 PREVIOUS##Shift + PREVIOUS##Width; \
672 static constexpr storage_type NAME##Width = WIDTH; \
673 static constexpr storage_type NAME##Mask = ((1 << NAME##Width) - 1) \
675 #include "clang/Basic/FPOptions.def"
678 #define OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
679 #include "clang/Basic/FPOptions.def"
691 setConstRoundingMode(RoundingMode::Dynamic);
699 auto LangOptContractMode = LO.getDefaultFPContractMode();
702 setFPContractMode(LangOptContractMode);
703 setRoundingMath(LO.RoundingMath);
704 setConstRoundingMode(LangOptions::RoundingMode::Dynamic);
705 setSpecifiedExceptionMode(LO.getFPExceptionMode());
706 setAllowFPReassociate(LO.AllowFPReassoc);
707 setNoHonorNaNs(LO.NoHonorNaNs);
708 setNoHonorInfs(LO.NoHonorInfs);
709 setNoSignedZero(LO.NoSignedZero);
710 setAllowReciprocal(LO.AllowRecip);
711 setAllowApproxFunc(LO.ApproxFunc);
717 setAllowFEnvAccess(
true);
739 getAllowFEnvAccess();
744 if (RM == RoundingMode::Dynamic) {
748 if (!getAllowFEnvAccess() && !getRoundingMath())
749 RM = RoundingMode::NearestTiesToEven;
756 if (EM == LangOptions::FPExceptionModeKind::FPE_Default) {
757 if (getAllowFEnvAccess())
758 return LangOptions::FPExceptionModeKind::FPE_Strict;
760 return LangOptions::FPExceptionModeKind::FPE_Ignore;
782 #define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
783 TYPE get##NAME() const { \
784 return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift); \
786 void set##NAME(TYPE value) { \
787 Value = (Value & ~NAME##Mask) | (storage_type(value) << NAME##Shift); \
789 #include "clang/Basic/FPOptions.def"
790 LLVM_DUMP_METHOD
void dump();
817 "Too short type for FPOptionsOverride");
830 : Options(FPO), OverrideMask(Mask) {}
847 setAllowFPReassociateOverride(!
Value);
848 setNoHonorNaNsOverride(!
Value);
849 setNoHonorInfsOverride(!
Value);
850 setNoSignedZeroOverride(!
Value);
851 setAllowReciprocalOverride(!
Value);
852 setAllowApproxFuncOverride(!
Value);
862 return (
static_cast<storage_type>(Options.getAsOpaqueInt())
876 (Options.getAsOpaqueInt() & OverrideMask));
885 return Options == other.Options && OverrideMask == other.OverrideMask;
889 #define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
890 bool has##NAME##Override() const { \
891 return OverrideMask & FPOptions::NAME##Mask; \
893 TYPE get##NAME##Override() const { \
894 assert(has##NAME##Override()); \
895 return Options.get##NAME(); \
897 void clear##NAME##Override() { \
900 Options.set##NAME(TYPE(0)); \
901 OverrideMask &= ~FPOptions::NAME##Mask; \
903 void set##NAME##Override(TYPE value) { \
904 Options.set##NAME(value); \
905 OverrideMask |= FPOptions::NAME##Mask; \
907 #include "clang/Basic/FPOptions.def"
908 LLVM_DUMP_METHOD
void dump();
914 return getChangesSlow(
Base);
936 #endif // LLVM_CLANG_BASIC_LANGOPTIONS_H
SignReturnAddressScopeKind
@ PPTMK_FullGeneralitySingleInheritance
bool operator==(FPOptionsOverride other) const
std::string CurrentModule
The name of the current module, of which the main source file is a part.
void setAllowFPContractAcrossStatement()
bool isExplicitDefaultVisibilityExportMapping() const
bool isSignedOverflowDefined() const
bool hasSEHExceptions() const
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
std::vector< std::string > XRayAlwaysInstrumentFiles
Paths to the XRay "always instrument" files specifying which objects (files, functions,...
bool isFPConstrained() const
@ OneZeroOrIncomplete
Any trailing array member of undefined, 0, or 1 size is a FAM.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
@ Swift
Interoperability with the latest known version of the Swift runtime.
bool isSignReturnAddressScopeAll() const
Check if leaf functions are also signed.
bool requiresTrailingStorage() const
@ Latest
Conform to the underlying platform's C and C++ ABIs as closely as we can.
static constexpr storage_type FirstShift
bool isCompilingModule() const
Are we compiling a module?
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
@ Ver11
Attempt to be ABI-compatible with code generated by Clang 11.0.x (git 2e10b7a39b93).
bool assumeFunctionsAreConvergent() const
@ FPE_MayTrap
Transformations do not cause new exceptions but may hide some.
bool operator==(FPOptions other) const
@ Unspecified
No interoperability ABI has been specified.
CoreFoundationABI CFRuntime
static constexpr storage_type OverrideMaskBits
Bit mask selecting bits of OverrideMask in serialized representation of FPOptionsOverride.
std::string ObjCConstantStringClass
bool allowsNonTrivialObjCLifetimeQualifiers() const
True if any ObjC types may have non-trivial lifetime qualifiers.
@ NonLeaf
Sign the return address of functions that spill LR.
@ None
No signing for any function.
RoundingMode getDefaultRoundingMode() const
FPOptions(const LangOptions &LO)
@ CMK_ModuleMap
Compiling a module from a module map.
std::vector< std::string > XRayAttrListFiles
Paths to the XRay attribute list files, specifying which objects (files, functions,...
@ Swift4_1
Interoperability with the Swift 4.1 runtime.
bool implicitFunctionsAllowed() const
Returns true if implicit function declarations are allowed in the current language mode.
bool isCompilingModuleInterface() const
Are we compiling a standard c++ module interface?
void setAllowFPContractWithinStatement()
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
bool hasDWARFExceptions() const
void setFPPreciseEnabled(bool Value)
std::map< std::string, std::string, std::greater< std::string > > MacroPrefixMap
A prefix map for FILE, BASE_FILE and __builtin_FILE().
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
llvm::RoundingMode RoundingMode
@ AKey
Return address signing uses APIA key.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
@ All
map all default visibilities to exported
@ PPTMK_FullGeneralityVirtualInheritance
FPOptionsOverride(const LangOptions &LO)
bool SanitizeCoverage
Is at least one coverage instrumentation type enabled.
@ TU_Module
The translation unit is a module.
storage_type getAsOpaqueInt() const
bool isCompilingModuleImplementation() const
Are we compiling a module implementation?
@ Ver12
Attempt to be ABI-compatible with code generated by Clang 12.0.x (git 8e464dd76bef).
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
RoundingMode getRoundingMode() const
FPOptions applyOverrides(const LangOptions &LO)
clang::ObjCRuntime ObjCRuntime
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
@ CMK_None
Not compiling a module interface at all.
@ ObjectiveC
Interoperability with the ObjectiveC runtime.
bool isImplicitIntRequired() const
Returns true if implicit int is part of the language requirements.
bool hasWasmExceptions() const
Bitfields of LangOptions, split out from LangOptions in order to ensure that this large collection of...
Represents difference between two FPOptions values.
LangOptions::FPExceptionModeKind getExceptionMode() const
FPExceptionModeKind
Possible floating point exception behavior.
@ TU_Incremental
The translation unit is a is a complete translation unit that we might incrementally extend later.
bool allowFPContractWithinStatement() const
FPEvalMethodKind
Possible float expression evaluation method choices.
FPOptions applyOverrides(FPOptions Base)
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
bool hasSjLjExceptions() const
@ Swift5_0
Interoperability with the Swift 5.0 runtime.
FPOptionsOverride(FPOptions FPO)
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
@ ExtendTo32
Integer arguments are sign or zero extended to 32/64 bits during default argument promotions.
@ Ver4
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
FPExceptionModeKind getDefaultExceptionMode() const
static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO)
Return the default value of FPOptions that's used when trailing storage isn't required.
bool isNoBuiltinFunc(StringRef Name) const
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* optio...
ClangABI
Clang versions with different platform ABI conformance.
bool isAllDefaultVisibilityExportMapping() const
Visibility
Describes the different kinds of visibility that a declaration may have.
SanitizerSet Sanitize
Set of enabled sanitizers.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
std::vector< std::string > XRayNeverInstrumentFiles
Paths to the XRay "never instrument" files specifying which objects (files, functions,...
@ FEM_Indeterminable
The evaluation method cannot be determined or is inconsistent for this target.
std::optional< TargetCXXABI::Kind > CXXABI
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
bool operator!=(FPOptionsOverride other) const
bool UseTargetPathSeparator
Indicates whether the FILE macro should use the target's platform-specific file separator or whether ...
bool hasDefaultVisibilityExportMapping() const
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
FPOptionsOverride getChangesFrom(const FPOptions &Base) const
Return difference with the given option set.
@ FEM_Source
Use the declared type for fp arithmetic.
ExceptionHandlingKind
Possible exception handling behavior.
Language
The language for the input, used to select and validate the language standard and possible actions.
std::vector< std::string > NoSanitizeFiles
Paths to files specifying which objects (files, functions, variables) should not be instrumented.
StrictFlexArraysLevelKind
@ Explicit
map only explicit default visibilities to exported
@ Default
Any trailing array member is a FAM.
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
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...
@ Ver3_8
Attempt to be ABI-compatible with code generated by Clang 3.8.x (SVN r257626).
GPUDefaultStreamKind GPUDefaultStream
The default stream kind used for HIP kernel launching.
@ Single
Single Threaded Environment.
static constexpr storage_type TotalWidth
bool isImplicitIntAllowed() const
Returns true if implicit int is supported at all.
bool hasSignReturnAddress() const
Check if return address signing is enabled.
std::string CUID
The user provided compilation unit ID, if non-empty.
The basic abstraction for the target Objective-C runtime.
bool isSubscriptPointerArithmetic() const
LangStandard::Kind LangStd
The used language standard.
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...
@ None
Permit no implicit vector bitcasts.
std::vector< std::string > ProfileListFiles
Paths to special case list files specifying which entities (files, functions) should or should not be...
TranslationUnitKind
Describes the kind of translation unit being processed.
@ Ver9
Attempt to be ABI-compatible with code generated by Clang 9.0.x (SVN r351319).
static FPOptionsOverride getFromOpaqueInt(storage_type I)
@ Ver15
Attempt to be ABI-compatible with code generated by Clang 15.0.x.
@ IncompleteOnly
Any trailing array member of undefined size is a FAM.
@ ZeroOrIncomplete
Any trailing array member of undefined or 0 size is a FAM.
PragmaMSPointersToMembersKind
@ FEM_Double
Use the type double for fp arithmetic.
@ PerThread
Per-thread default stream.
std::string RandstructSeed
The seed used by the randomize structure layout feature.
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
bool isSignReturnAddressWithAKey() const
Check if return address signing uses AKey.
@ Standalone
CoreFoundation does not have any language interoperability.
storage_type getAsOpaqueInt() const
@ Legacy
Legacy default stream.
@ BKey
Return address signing uses APIB key.
void setDisallowFPContract()
Helper class for holding the data necessary to invoke the compiler.
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
FPOptionsOverride(FPOptions FPO, FPOptions::storage_type Mask)
bool trackLocalOwningModule() const
Do we need to track the owning module for a local declaration?
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
static FPOptions getFromOpaqueInt(storage_type Value)
uint64_t storage_type
The type suitable for storing values of FPOptionsOverride.
@ TU_Complete
The translation unit is a complete translation unit.
CommentOptions CommentOpts
Options for parsing comments.
void remapPathPrefix(SmallVectorImpl< char > &Path) const
Remap path prefix according to -fmacro-prefix-path option.
@ FEM_Extended
Use extended type for fp arithmetic.
@ Ver14
Attempt to be ABI-compatible with code generated by Clang 14.0.x.
@ All
Sign the return address of all functions,.
@ PPTMK_FullGeneralityMultipleInheritance
ShaderStage
Shader programs run in specific pipeline stages.
@ FPE_Default
Used internally to represent initial unspecified value.
@ Ver7
Attempt to be ABI-compatible with code generated by Clang 7.0.x (SVN r338536).
bool allowFPContractAcrossStatement() const
void setAllowFPContractWithinStatement()
LLVM_DUMP_METHOD void dump()
static constexpr storage_type FirstWidth
static constexpr unsigned StorageBitSize
DefaultVisiblityExportMapping
bool isSubscriptPointerArithmetic() const
Is subscripting pointer arithmetic?
std::string ModuleName
The module currently being compiled as specified by -fmodule-name.
@ Ver6
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
void setAllowFPContractAcrossStatement()
@ CMK_HeaderUnit
Compiling a module header unit.
llvm::RoundingMode RoundingMode
@ Swift4_2
Interoperability with the Swift 4.2 runtime.
llvm::RoundingMode RoundingMode