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/TargetParser/Triple.h"
41#define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
42#define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
43#include "clang/Basic/LangOptions.def"
48#define LANGOPT(Name, Bits, Default, Description)
49#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
51#include "clang/Basic/LangOptions.def"
481 std::optional<TargetCXXABI::Kind>
CXXABI;
523 std::vector<std::string> &Includes,
527#define LANGOPT(Name, Bits, Default, Description)
528#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
529 Type get##Name() const { return static_cast<Type>(Name); } \
530 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
531#include "clang/Basic/LangOptions.def"
535 return getCompilingModule() !=
CMK_None;
559 !ObjCSubscriptingLegacyRuntime;
563 return MSCompatibilityVersion >= MajorVersion * 100000U;
576 return ObjCAutoRefCount || ObjCWeak;
580 return ConvergentFunctions;
606 bool hasAtExit()
const {
return !(OpenMP && OpenMPIsTargetDevice); }
645 bool isSYCL()
const {
return SYCLIsDevice || SYCLIsHost; }
648 return getDefaultVisibilityExportMapping() !=
653 return getDefaultVisibilityExportMapping() ==
658 return getDefaultVisibilityExportMapping() ==
666 return RoundingMath ? RoundingMode::Dynamic
667 : RoundingMode::NearestTiesToEven;
679class FPOptionsOverride;
692#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
693 static constexpr storage_type NAME##Shift = \
694 PREVIOUS##Shift + PREVIOUS##Width; \
695 static constexpr storage_type NAME##Width = WIDTH; \
696 static constexpr storage_type NAME##Mask = ((1 << NAME##Width) - 1) \
698#include "clang/Basic/FPOptions.def"
701#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
702#include "clang/Basic/FPOptions.def"
714 setConstRoundingMode(RoundingMode::Dynamic);
722 auto LangOptContractMode = LO.getDefaultFPContractMode();
725 setFPContractMode(LangOptContractMode);
726 setRoundingMath(LO.RoundingMath);
727 setConstRoundingMode(LangOptions::RoundingMode::Dynamic);
728 setSpecifiedExceptionMode(LO.getFPExceptionMode());
729 setAllowFPReassociate(LO.AllowFPReassoc);
730 setNoHonorNaNs(LO.NoHonorNaNs);
731 setNoHonorInfs(LO.NoHonorInfs);
732 setNoSignedZero(LO.NoSignedZero);
733 setAllowReciprocal(LO.AllowRecip);
734 setAllowApproxFunc(LO.ApproxFunc);
740 setAllowFEnvAccess(
true);
762 getAllowFEnvAccess();
767 if (RM == RoundingMode::Dynamic) {
771 if (!getAllowFEnvAccess() && !getRoundingMath())
772 RM = RoundingMode::NearestTiesToEven;
780 if (getAllowFEnvAccess())
805#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
806 TYPE get##NAME() const { \
807 return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift); \
809 void set##NAME(TYPE value) { \
810 Value = (Value & ~NAME##Mask) | (storage_type(value) << NAME##Shift); \
812#include "clang/Basic/FPOptions.def"
813 LLVM_DUMP_METHOD
void dump();
840 "Too short type for FPOptionsOverride");
853 : Options(FPO), OverrideMask(Mask) {}
870 setAllowFPReassociateOverride(!
Value);
871 setNoHonorNaNsOverride(!
Value);
872 setNoHonorInfsOverride(!
Value);
873 setNoSignedZeroOverride(!
Value);
874 setAllowReciprocalOverride(!
Value);
875 setAllowApproxFuncOverride(!
Value);
876 setMathErrnoOverride(
Value);
886 return (
static_cast<storage_type>(Options.getAsOpaqueInt())
900 (Options.getAsOpaqueInt() & OverrideMask));
909 return Options == other.Options && OverrideMask == other.OverrideMask;
913#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
914 bool has##NAME##Override() const { \
915 return OverrideMask & FPOptions::NAME##Mask; \
917 TYPE get##NAME##Override() const { \
918 assert(has##NAME##Override()); \
919 return Options.get##NAME(); \
921 void clear##NAME##Override() { \
924 Options.set##NAME(TYPE(0)); \
925 OverrideMask &= ~FPOptions::NAME##Mask; \
927 void set##NAME##Override(TYPE value) { \
928 Options.set##NAME(value); \
929 OverrideMask |= FPOptions::NAME##Mask; \
931#include "clang/Basic/FPOptions.def"
932 LLVM_DUMP_METHOD
void dump();
938 return getChangesSlow(
Base);
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.
The base class of CompilerInvocation.
Helper class for holding the data necessary to invoke the compiler.
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
FPOptions applyOverrides(const LangOptions &LO)
uint64_t storage_type
The type suitable for storing values of FPOptionsOverride.
FPOptionsOverride(const LangOptions &LO)
bool requiresTrailingStorage() const
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...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
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.
bool hasWasmExceptions() const
std::optional< TargetCXXABI::Kind > CXXABI
C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
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.
bool hasSjLjExceptions() const
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
bool isCompilingModuleInterface() const
Are we compiling a standard c++ module interface?
bool hasDefaultVisibilityExportMapping() const
SanitizerSet Sanitize
Set of enabled sanitizers.
CommentOptions CommentOpts
Options for parsing comments.
bool isExplicitDefaultVisibilityExportMapping() const
@ CMK_HeaderUnit
Compiling a module header unit.
@ CMK_ModuleMap
Compiling a module from a module map.
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
@ CMK_None
Not compiling a module interface at all.
std::vector< std::string > XRayAlwaysInstrumentFiles
Paths to the XRay "always instrument" files specifying which objects (files, functions,...
DefaultVisiblityExportMapping
@ Explicit
map only explicit default visibilities to exported
@ All
map all default visibilities to exported
@ 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.
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?
ExceptionHandlingKind
Possible exception handling behavior.
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...
bool isSignedOverflowDefined() const
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
llvm::RoundingMode RoundingMode
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 hasDWARFExceptions() const
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.
@ BKey
Return address signing uses APIB key.
@ AKey
Return address signing uses APIA key.
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.
@ ExtendTo32
Integer arguments are sign or zero extended to 32/64 bits during default argument promotions.
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
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,.
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.
ClangABI
Clang versions with different platform ABI conformance.
@ Ver6
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
@ Ver4
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
@ Ver14
Attempt to be ABI-compatible with code generated by Clang 14.0.x.
@ Ver11
Attempt to be ABI-compatible with code generated by Clang 11.0.x (git 2e10b7a39b93).
@ Ver15
Attempt to be ABI-compatible with code generated by Clang 15.0.x.
@ Ver17
Attempt to be ABI-compatible with code generated by Clang 17.0.x.
@ Ver7
Attempt to be ABI-compatible with code generated by Clang 7.0.x (SVN r338536).
@ Latest
Conform to the underlying platform's C and C++ ABIs as closely as we can.
@ Ver3_8
Attempt to be ABI-compatible with code generated by Clang 3.8.x (SVN r257626).
@ Ver12
Attempt to be ABI-compatible with code generated by Clang 12.0.x (git 8e464dd76bef).
@ Ver9
Attempt to be ABI-compatible with code generated by Clang 9.0.x (SVN r351319).
FPExceptionModeKind
Possible floating point exception behavior.
@ FPE_Default
Used internally to represent initial unspecified value.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
@ FPE_MayTrap
Transformations do not cause new exceptions but may hide some.
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
LangStandard::Kind LangStd
The used language standard.
RoundingMode getDefaultRoundingMode() const
@ Legacy
Legacy default stream.
@ PerThread
Per-thread default stream.
bool isCompilingModule() const
Are we compiling a module?
@ Integer
Permit vector bitcasts between integer vectors with different numbers of elements but the same total ...
@ All
Permit vector bitcasts between all vectors with the same total bit-width.
bool isImplicitIntRequired() const
Returns true if implicit int is part of the language requirements.
bool hasSEHExceptions() const
FPEvalMethodKind
Possible float expression evaluation method choices.
@ FEM_UnsetOnCommandLine
Used only for FE option processing; this is only used to indicate that the user did not specify an ex...
@ FEM_Indeterminable
The evaluation method cannot be determined or is inconsistent for this target.
@ FEM_Source
Use the declared type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_Extended
Use extended type for fp arithmetic.
std::string OpenACCMacroOverride
bool isSignReturnAddressScopeAll() const
Check if leaf functions are also signed.
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.
PragmaMSPointersToMembersKind
@ PPTMK_FullGeneralityMultipleInheritance
@ PPTMK_FullGeneralityVirtualInheritance
@ PPTMK_FullGeneralitySingleInheritance
@ Single
Single Threaded Environment.
GPUDefaultStreamKind GPUDefaultStream
The default stream kind used for HIP kernel launching.
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.
bool isSubscriptPointerArithmetic() const
Is subscripting pointer arithmetic?
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_Module
The translation unit is a module.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
Visibility
Describes the different kinds of visibility that a declaration may have.