clang: include/clang/Basic/LangOptions.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
15#define LLVM_CLANG_BASIC_LANGOPTIONS_H
16
25#include "llvm/ADT/FloatingPointMode.h"
26#include "llvm/ADT/StringRef.h"
27#include "llvm/TargetParser/Triple.h"
28#include
29#include
30#include
31
33
34
35
37
38
39
40
41
59};
60
66};
67
68
69
73
74public:
78
81
82
83
84
86
88
90
91
93
94
97
98
100
102
103
105
106
108
109
111 };
112
119
121
131
133
134
147 };
148
153
154
157
167 };
168
169
171
172
173
175
176
177
178
180
181
182
183
184
185
187
188
189
190
191
193
194
195
196
197
199
200
201
202
203
204
205
207
208
209
210
212
213
214
215
216
217
218
220
221
222
223
224
225
227
228
229
230
231
232
233
234
236
237
238
239
241
242
243
244
245
246
247
249
250
251
253 };
254
256
258
260
262
264
266
268
270 };
271
273
275
276
278
279
281
282
285
286
288
290
292
294
297
298
300
301
303
305
307
309
310
311
312
315
317
318
320
322
324
325
327
328
330 };
331
333
334
336
338
340
342 };
343
345
347
349
351 };
352
354
356
358 };
359
361
363
365 };
366
368
369
372 };
373
375
377
379 };
380
381
382
384
386
388
390
392
394
396 };
397
400
402
404 };
405
407
409
411
413
415 };
416
418
420
422
424
426 };
427
429
431
433
435
437 };
438
439
440
442
443
444
445
446
448
449
450
451
453
454
455
456
457
458
459
460
462
463
464
465
467
468
471
472
474
476
478
480 };
481
482
483#define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
484#define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
485#include "clang/Basic/LangOptions.def"
486
487protected:
488
489
490#define LANGOPT(Name, Bits, Default, Description)
491#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
492 LLVM_PREFERRED_TYPE(Type) \
493 unsigned Name : Bits;
494#include "clang/Basic/LangOptions.def"
495};
496
497
498
500public:
501
503
504
506
508
509
510
512
513
514
515
516
518
519
520
521
522
524
525
526
527
529
530
531
533
535
537
539
540
541
542
543
545
546
548
549
550
551
552
553
555
556
557
558
559
561
562
564
565
567
568
569 std::map<std::string, std::string, std::greaterstd::string> MacroPrefixMap;
570
571
572
574
575
576
578
579
580
581
582
584
585
586
587 std::optionalTargetCXXABI::Kind CXXABI;
588
589
590
592
593
595
596
598
600
601
603
604
605
606
607
608
609
611
612
613
615
616
617
618
620
621
622
624
626
627
628
629
630
631
632
633
634
635
636 static void
638 std::vectorstd::string &Includes,
640
641
642#define LANGOPT(Name, Bits, Default, Description)
643#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
644 Type get##Name() const { return static_cast(Name); } \
645 void set##Name(Type Value) { Name = static_cast(Value); }
646#include "clang/Basic/LangOptions.def"
647
648
650 return getCompilingModule() != CMK_None;
651 }
652
653
656 }
657
658
661 }
662
664 return getSignedOverflowBehavior() == SOB_Defined;
665 }
666
669 !ObjCSubscriptingLegacyRuntime;
670 }
671
673 return MSCompatibilityVersion >= MajorVersion * 100000U;
674 }
675
678 return false;
680 return true;
682 }
683
684
685
687
688
689
691
692
694 return ObjCAutoRefCount || ObjCWeak;
695 }
696
698 return ConvergentFunctions;
699 }
700
701
702
704
705
707 }
708
709
711
712
714
715
716
718
719
720
722 return CPlusPlus || C23 || DisableKNRFunctions;
723 }
724
725
726
729 }
730
731
732 bool hasAtExit() const { return !(OpenMP && OpenMPIsTargetDevice); }
733
734
736
737
739
740
743 }
744
745
748 }
749
750
753 }
754
757 }
758
761 }
762
765 }
766
769 }
770
771 bool isSYCL() const { return SYCLIsDevice || SYCLIsHost; }
772
774 return getDefaultVisibilityExportMapping() !=
776 }
777
779 return getDefaultVisibilityExportMapping() ==
781 }
782
784 return getDefaultVisibilityExportMapping() ==
786 }
787
789 return getGlobalAllocationFunctionVisibility() !=
791 }
792
794 return getGlobalAllocationFunctionVisibility() ==
796 }
797
799 return getGlobalAllocationFunctionVisibility() ==
801 }
802
804 return getGlobalAllocationFunctionVisibility() ==
806 }
807
808
810
812 return RoundingMath ? RoundingMode::Dynamic
813 : RoundingMode::NearestTiesToEven;
814 }
815
820 return EM;
821 }
822};
823
824
825class FPOptionsOverride;
827public:
828
830
832
834
835
836
838#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
839 static constexpr storage_type NAME##Shift = \
840 PREVIOUS##Shift + PREVIOUS##Width; \
841 static constexpr storage_type NAME##Width = WIDTH; \
842 static constexpr storage_type NAME##Mask = ((1 << NAME##Width) - 1) \
843 << NAME##Shift;
844#include "clang/Basic/FPOptions.def"
845
847#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
848#include "clang/Basic/FPOptions.def"
849 ;
851
852private:
854
856
857public:
860 setConstRoundingMode(RoundingMode::Dynamic);
862 }
865
866
867
868 auto LangOptContractMode = LO.getDefaultFPContractMode();
871 setFPContractMode(LangOptContractMode);
872 setRoundingMath(LO.RoundingMath);
873 setConstRoundingMode(LangOptions::RoundingMode::Dynamic);
874 setSpecifiedExceptionMode(LO.getFPExceptionMode());
875 setAllowFPReassociate(LO.AllowFPReassoc);
876 setNoHonorNaNs(LO.NoHonorNaNs);
877 setNoHonorInfs(LO.NoHonorInfs);
878 setNoSignedZero(LO.NoSignedZero);
879 setAllowReciprocal(LO.AllowRecip);
880 setAllowApproxFunc(LO.ApproxFunc);
884
885
886 setAllowFEnvAccess(true);
887 else
889 setComplexRange(LO.getComplexRange());
890 }
891
894 }
897 }
898
901 }
904 }
905
907 return getRoundingMode() != llvm::RoundingMode::NearestTiesToEven ||
909 getAllowFEnvAccess();
910 }
911
914 if (RM == RoundingMode::Dynamic) {
915
916
917
918 if (!getAllowFEnvAccess() && !getRoundingMath())
919 RM = RoundingMode::NearestTiesToEven;
920 }
921 return RM;
922 }
923
927 if (getAllowFEnvAccess())
929 else
931 }
932 return EM;
933 }
934
936
937
938
940
944 Opts.Value = Value;
945 return Opts;
946 }
947
948
950
952
953
954#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
955 TYPE get##NAME() const { \
956 return static_cast((Value & NAME##Mask) >> NAME##Shift); \
957 } \
958 void set##NAME(TYPE value) { \
959 Value = (Value & ~NAME##Mask) | (storage_type(value) << NAME##Shift); \
960 }
961#include "clang/Basic/FPOptions.def"
962 LLVM_DUMP_METHOD void dump();
963};
964
965
966
967
968
969
970
971
972
973
974
975
976
977
981
982public:
984
985
986
989 "Too short type for FPOptionsOverride");
990
991
992
995
1002 : Options(FPO), OverrideMask(Mask) {}
1003
1005
1008 }
1009
1012 }
1013
1016 }
1017
1019 setAllowFPReassociateOverride();
1020 setNoHonorNaNsOverride();
1021 setNoHonorInfsOverride();
1022 setNoSignedZeroOverride();
1023 setAllowReciprocalOverride();
1024 setAllowApproxFuncOverride();
1025 setMathErrnoOverride(Value);
1027
1029 else
1030
1032 }
1033
1035
1037 return (static_cast<storage_type>(Options.getAsOpaqueInt())
1039 OverrideMask;
1040 }
1045 return Opts;
1046 }
1047
1051 (Options.getAsOpaqueInt() & OverrideMask));
1053 }
1054
1057 }
1058
1060 return Options == other.Options && OverrideMask == other.OverrideMask;
1061 }
1063
1064#define OPTION(NAME, TYPE, WIDTH, PREVIOUS) \
1065 bool has##NAME##Override() const { \
1066 return OverrideMask & FPOptions::NAME##Mask; \
1067 } \
1068 TYPE get##NAME##Override() const { \
1069 assert(has##NAME##Override()); \
1070 return Options.get##NAME(); \
1071 } \
1072 void clear##NAME##Override() { \
1073
1074 \
1075 Options.set##NAME(TYPE(0)); \
1076 OverrideMask &= ~FPOptions::NAME##Mask; \
1077 } \
1078 void set##NAME##Override(TYPE value) { \
1079 Options.set##NAME(value); \
1080 OverrideMask |= FPOptions::NAME##Mask; \
1081 }
1082#include "clang/Basic/FPOptions.def"
1083 LLVM_DUMP_METHOD void dump();
1084};
1089 return getChangesSlow(Base);
1090}
1094}
1095
1100
1101
1104
1107
1108
1109
1111};
1112
1113}
1114
1115#endif
enum clang::sema::@1725::IndirectLocalPathEntry::EntryKind Kind
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
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...
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
@ 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.
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_Indeterminable
The evaluation method cannot be determined or is inconsistent for this target.
@ 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.
@ 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.
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–)
ExceptionHandlingKind
Possible exception handling behavior.
DefaultVisiblityExportMapping
@ Explicit
map only explicit default visibilities to exported
@ All
map all default visibilities to exported
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.
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.
@ Ver6
Attempt to be ABI-compatible with code generated by Clang 6.0.x (SVN r321711).
@ Ver18
Attempt to be ABI-compatible with code generated by Clang 18.0.x.
@ 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).
@ Ver19
Attempt to be ABI-compatible with code generated by Clang 19.0.x.
@ 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).
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...
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
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
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.
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...
bool isSignedOverflowDefined() const
bool hasDefaultGlobalAllocationFunctionVisibility() const
bool hasGlobalAllocationFunctionVisibility() const
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
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
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
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
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 hasProtectedGlobalAllocationFunctionVisibility() const
LangStandard::Kind LangStd
The used language standard.
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 hasSEHExceptions() const
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.
GPUDefaultStreamKind GPUDefaultStream
The default stream kind used for HIP kernel launching.
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.
bool isSubscriptPointerArithmetic() const
Is subscripting pointer arithmetic?
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.
const FunctionProtoType * T
PointerAuthenticationMode
@ None
The alignment was not explicit in code.
Visibility
Describes the different kinds of visibility that a declaration may have.