xref: /freebsd/contrib/llvm-project/clang/include/clang/Basic/LangOptions.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 //===- LangOptions.h - C Language Family Language Options -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Defines the clang::LangOptions interface.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
15 #define LLVM_CLANG_BASIC_LANGOPTIONS_H
16 
17 #include "clang/Basic/CFProtectionOptions.h"
18 #include "clang/Basic/CommentOptions.h"
19 #include "clang/Basic/LLVM.h"
20 #include "clang/Basic/LangStandard.h"
21 #include "clang/Basic/ObjCRuntime.h"
22 #include "clang/Basic/Sanitizers.h"
23 #include "clang/Basic/TargetCXXABI.h"
24 #include "clang/Basic/Visibility.h"
25 #include "llvm/ADT/FloatingPointMode.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/BinaryFormat/DXContainer.h"
28 #include "llvm/TargetParser/Triple.h"
29 #include <optional>
30 #include <string>
31 #include <vector>
32 
33 namespace clang {
34 
35 /// In the Microsoft ABI, this controls the placement of virtual displacement
36 /// members used to implement virtual inheritance.
37 enum class MSVtorDispMode { Never, ForVBaseOverride, ForVFTable };
38 
39 /// Shader programs run in specific pipeline stages.
40 /// The order of these values matters, and must be kept in sync with the
41 /// Triple Environment enum in llvm::Triple. The ordering is enforced in
42 ///  static_asserts in Triple.cpp and in clang/Basic/HLSLRuntime.h.
43 enum class ShaderStage {
44   Pixel = 0,
45   Vertex,
46   Geometry,
47   Hull,
48   Domain,
49   Compute,
50   Library,
51   RayGeneration,
52   Intersection,
53   AnyHit,
54   ClosestHit,
55   Miss,
56   Callable,
57   Mesh,
58   Amplification,
59   Invalid,
60 };
61 
62 enum class PointerAuthenticationMode : unsigned {
63   None,
64   Strip,
65   SignAndStrip,
66   SignAndAuth
67 };
68 
69 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
70 /// this large collection of bitfields is a trivial class type.
71 class LangOptionsBase {
72   friend class CompilerInvocation;
73   friend class CompilerInvocationBase;
74 
75 public:
76   using Visibility = clang::Visibility;
77   using RoundingMode = llvm::RoundingMode;
78   using CFBranchLabelSchemeKind = clang::CFBranchLabelSchemeKind;
79 
80   /// For ASTs produced with different option value, signifies their level of
81   /// compatibility.
82   enum class CompatibilityKind {
83     /// Does affect the construction of the AST in a way that does prevent
84     /// module interoperability.
85     NotCompatible,
86     /// Does affect the construction of the AST in a way that doesn't prevent
87     /// interoperability (that is, the value can be different between an
88     /// explicit module and the user of that module).
89     Compatible,
90     /// Does not affect the construction of the AST in any way (that is, the
91     /// value can be different between an implicit module and the user of that
92     /// module).
93     Benign,
94   };
95 
96   enum GCMode { NonGC, GCOnly, HybridGC };
97   enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
98 
99   // Automatic variables live on the stack, and when trivial they're usually
100   // uninitialized because it's undefined behavior to use them without
101   // initializing them.
102   enum class TrivialAutoVarInitKind { Uninitialized, Zero, Pattern };
103 
104   enum SignedOverflowBehaviorTy {
105     // Default C standard behavior.
106     SOB_Undefined,
107 
108     // -fwrapv
109     SOB_Defined,
110 
111     // -ftrapv
112     SOB_Trapping
113   };
114 
115   // FIXME: Unify with TUKind.
116   enum CompilingModuleKind {
117     /// Not compiling a module interface at all.
118     CMK_None,
119 
120     /// Compiling a module from a module map.
121     CMK_ModuleMap,
122 
123     /// Compiling a module header unit.
124     CMK_HeaderUnit,
125 
126     /// Compiling a C++ modules interface unit.
127     CMK_ModuleInterface,
128   };
129 
130   enum PragmaMSPointersToMembersKind {
131     PPTMK_BestCase,
132     PPTMK_FullGeneralitySingleInheritance,
133     PPTMK_FullGeneralityMultipleInheritance,
134     PPTMK_FullGeneralityVirtualInheritance
135   };
136 
137   using MSVtorDispMode = clang::MSVtorDispMode;
138 
139   enum DefaultCallingConvention {
140     DCC_None,
141     DCC_CDecl,
142     DCC_FastCall,
143     DCC_StdCall,
144     DCC_VectorCall,
145     DCC_RegCall,
146     DCC_RtdCall
147   };
148 
149   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
150 
151   // Corresponds to _MSC_VER
152   enum MSVCMajorVersion {
153     MSVC2010 = 1600,
154     MSVC2012 = 1700,
155     MSVC2013 = 1800,
156     MSVC2015 = 1900,
157     MSVC2017 = 1910,
158     MSVC2017_5 = 1912,
159     MSVC2017_7 = 1914,
160     MSVC2019 = 1920,
161     MSVC2019_5 = 1925,
162     MSVC2019_8 = 1928,
163     MSVC2022_3 = 1933,
164     MSVC2022_9 = 1939,
165   };
166 
167   enum SYCLMajorVersion {
168     SYCL_None,
169     SYCL_2017,
170     SYCL_2020,
171     // The "default" SYCL version to be used when none is specified on the
172     // frontend command line.
173     SYCL_Default = SYCL_2020
174   };
175 
176   enum HLSLLangStd {
177     HLSL_Unset = 0,
178     HLSL_2015 = 2015,
179     HLSL_2016 = 2016,
180     HLSL_2017 = 2017,
181     HLSL_2018 = 2018,
182     HLSL_2021 = 2021,
183     HLSL_202x = 2028,
184     HLSL_202y = 2029,
185   };
186 
187   /// Clang versions with different platform ABI conformance.
188   enum class ClangABI {
189     /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
190     /// (SVN r257626). This causes <1 x long long> to be passed in an
191     /// integer register instead of an SSE register on x64_64.
192     Ver3_8,
193 
194     /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
195     /// (SVN r291814). This causes move operations to be ignored when
196     /// determining whether a class type can be passed or returned directly.
197     Ver4,
198 
199     /// Attempt to be ABI-compatible with code generated by Clang 6.0.x
200     /// (SVN r321711). This causes determination of whether a type is
201     /// standard-layout to ignore collisions between empty base classes
202     /// and between base classes and member subobjects, which affects
203     /// whether we reuse base class tail padding in some ABIs.
204     Ver6,
205 
206     /// Attempt to be ABI-compatible with code generated by Clang 7.0.x
207     /// (SVN r338536). This causes alignof (C++) and _Alignof (C11) to be
208     /// compatible with __alignof (i.e., return the preferred alignment)
209     /// rather than returning the required alignment.
210     Ver7,
211 
212     /// Attempt to be ABI-compatible with code generated by Clang 9.0.x
213     /// (SVN r351319). This causes vectors of __int128 to be passed in memory
214     /// instead of passing in multiple scalar registers on x86_64 on Linux and
215     /// NetBSD.
216     Ver9,
217 
218     /// Attempt to be ABI-compatible with code generated by Clang 11.0.x
219     /// (git 2e10b7a39b93). This causes clang to pass unions with a 256-bit
220     /// vector member on the stack instead of using registers, to not properly
221     /// mangle substitutions for template names in some cases, and to mangle
222     /// declaration template arguments without a cast to the parameter type
223     /// even when that can lead to mangling collisions.
224     Ver11,
225 
226     /// Attempt to be ABI-compatible with code generated by Clang 12.0.x
227     /// (git 8e464dd76bef). This causes clang to mangle lambdas within
228     /// global-scope inline variables incorrectly.
229     Ver12,
230 
231     /// Attempt to be ABI-compatible with code generated by Clang 14.0.x.
232     /// This causes clang to:
233     ///   - mangle dependent nested names incorrectly.
234     ///   - make trivial only those defaulted copy constructors with a
235     ///     parameter-type-list equivalent to the parameter-type-list of an
236     ///     implicit declaration.
237     Ver14,
238 
239     /// Attempt to be ABI-compatible with code generated by Clang 15.0.x.
240     /// This causes clang to:
241     ///   - Reverse the implementation for DR692, DR1395 and DR1432.
242     ///   - pack non-POD members of packed structs.
243     ///   - consider classes with defaulted special member functions non-pod.
244     Ver15,
245 
246     /// Attempt to be ABI-compatible with code generated by Clang 17.0.x.
247     /// This causes clang to revert some fixes to its implementation of the
248     /// Itanium name mangling scheme, with the consequence that overloaded
249     /// function templates are mangled the same if they differ only by:
250     ///   - constraints
251     ///   - whether a non-type template parameter has a deduced type
252     ///   - the parameter list of a template template parameter
253     Ver17,
254 
255     /// Attempt to be ABI-compatible with code generated by Clang 18.0.x.
256     /// This causes clang to revert some fixes to the mangling of lambdas
257     /// in the initializers of members of local classes.
258     Ver18,
259 
260     /// Attempt to be ABI-compatible with code generated by Clang 19.0.x.
261     /// This causes clang to:
262     ///   - Incorrectly mangle the 'base type' substitutions of the CXX
263     ///   construction vtable because it hasn't added 'type' as a substitution.
264     ///   - Skip mangling enclosing class templates of member-like friend
265     ///   function templates.
266     ///   - Ignore empty struct arguments in C++ mode for ARM, instead of
267     ///   passing them as if they had a size of 1 byte.
268     Ver19,
269 
270     /// Attempt to be ABI-compatible with code generated by Clang 20.0.x.
271     /// This causes clang to:
272     ///   - Incorrectly return C++ records in AVX registers on x86_64.
273     Ver20,
274 
275     /// Conform to the underlying platform's C and C++ ABIs as closely
276     /// as we can.
277     Latest
278   };
279 
280   enum class CoreFoundationABI {
281     /// No interoperability ABI has been specified
282     Unspecified,
283     /// CoreFoundation does not have any language interoperability
284     Standalone,
285     /// Interoperability with the ObjectiveC runtime
286     ObjectiveC,
287     /// Interoperability with the latest known version of the Swift runtime
288     Swift,
289     /// Interoperability with the Swift 5.0 runtime
290     Swift5_0,
291     /// Interoperability with the Swift 4.2 runtime
292     Swift4_2,
293     /// Interoperability with the Swift 4.1 runtime
294     Swift4_1,
295   };
296 
297   enum FPModeKind {
298     // Disable the floating point pragma
299     FPM_Off,
300 
301     // Enable the floating point pragma
302     FPM_On,
303 
304     // Aggressively fuse FP ops (E.g. FMA) disregarding pragmas.
305     FPM_Fast,
306 
307     // Aggressively fuse FP ops and honor pragmas.
308     FPM_FastHonorPragmas
309   };
310 
311   /// Possible floating point exception behavior.
312   enum FPExceptionModeKind {
313     /// Assume that floating-point exceptions are masked.
314     FPE_Ignore,
315     /// Transformations do not cause new exceptions but may hide some.
316     FPE_MayTrap,
317     /// Strictly preserve the floating-point exception semantics.
318     FPE_Strict,
319     /// Used internally to represent initial unspecified value.
320     FPE_Default
321   };
322 
323   /// Possible float expression evaluation method choices.
324   enum FPEvalMethodKind : unsigned {
325     /// Use the declared type for fp arithmetic.
326     FEM_Source = 0,
327     /// Use the type double for fp arithmetic.
328     FEM_Double = 1,
329     /// Use extended type for fp arithmetic.
330     FEM_Extended = 2,
331     /// Used only for FE option processing; this is only used to indicate that
332     /// the user did not specify an explicit evaluation method on the command
333     /// line and so the target should be queried for its default evaluation
334     /// method instead.
335     FEM_UnsetOnCommandLine = 3
336   };
337 
338   enum ExcessPrecisionKind { FPP_Standard, FPP_Fast, FPP_None };
339 
340   /// Possible exception handling behavior.
341   enum class ExceptionHandlingKind { None, SjLj, WinEH, DwarfCFI, Wasm };
342 
343   enum class LaxVectorConversionKind {
344     /// Permit no implicit vector bitcasts.
345     None,
346     /// Permit vector bitcasts between integer vectors with different numbers
347     /// of elements but the same total bit-width.
348     Integer,
349     /// Permit vector bitcasts between all vectors with the same total
350     /// bit-width.
351     All,
352   };
353 
354   enum class AltivecSrcCompatKind {
355     // All vector compares produce scalars except vector pixel and vector bool.
356     // The types vector pixel and vector bool return vector results.
357     Mixed,
358     // All vector compares produce vector results as in GCC.
359     GCC,
360     // All vector compares produce scalars as in XL.
361     XL,
362     // Default clang behaviour.
363     Default = Mixed,
364   };
365 
366   enum class SignReturnAddressScopeKind {
367     /// No signing for any function.
368     None,
369     /// Sign the return address of functions that spill LR.
370     NonLeaf,
371     /// Sign the return address of all functions,
372     All
373   };
374 
375   enum class SignReturnAddressKeyKind {
376     /// Return address signing uses APIA key.
377     AKey,
378     /// Return address signing uses APIB key.
379     BKey
380   };
381 
382   enum class ThreadModelKind {
383     /// POSIX Threads.
384     POSIX,
385     /// Single Threaded Environment.
386     Single
387   };
388 
389   enum class ExtendArgsKind {
390     /// Integer arguments are sign or zero extended to 32/64 bits
391     /// during default argument promotions.
392     ExtendTo32,
393     ExtendTo64
394   };
395 
396   enum class GPUDefaultStreamKind {
397     /// Legacy default stream
398     Legacy,
399     /// Per-thread default stream
400     PerThread,
401   };
402 
403   /// Exclude certain code patterns from being instrumented by arithmetic
404   /// overflow sanitizers
405   enum OverflowPatternExclusionKind {
406     /// Don't exclude any overflow patterns from sanitizers
407     None = 1 << 0,
408     /// Exclude all overflow patterns (below)
409     All = 1 << 1,
410     /// if (a + b < a)
411     AddSignedOverflowTest = 1 << 2,
412     /// if (a + b < a)
413     AddUnsignedOverflowTest = 1 << 3,
414     /// -1UL
415     NegUnsignedConst = 1 << 4,
416     /// while (count--)
417     PostDecrInWhile = 1 << 5,
418   };
419 
420   enum class DefaultVisiblityExportMapping {
421     None,
422     /// map only explicit default visibilities to exported
423     Explicit,
424     /// map all default visibilities to exported
425     All,
426   };
427 
428   enum class VisibilityForcedKinds {
429     /// Force hidden visibility
430     ForceHidden,
431     /// Force protected visibility
432     ForceProtected,
433     /// Force default visibility
434     ForceDefault,
435     /// Don't alter the visibility
436     Source,
437   };
438 
439   enum class VisibilityFromDLLStorageClassKinds {
440     /// Keep the IR-gen assigned visibility.
441     Keep,
442     /// Override the IR-gen assigned visibility with default visibility.
443     Default,
444     /// Override the IR-gen assigned visibility with hidden visibility.
445     Hidden,
446     /// Override the IR-gen assigned visibility with protected visibility.
447     Protected,
448   };
449 
450   enum class StrictFlexArraysLevelKind {
451     /// Any trailing array member is a FAM.
452     Default = 0,
453     /// Any trailing array member of undefined, 0, or 1 size is a FAM.
454     OneZeroOrIncomplete = 1,
455     /// Any trailing array member of undefined or 0 size is a FAM.
456     ZeroOrIncomplete = 2,
457     /// Any trailing array member of undefined size is a FAM.
458     IncompleteOnly = 3,
459   };
460 
461   /// Controls the various implementations for complex multiplication and
462   // division.
463   enum ComplexRangeKind {
464     /// Implementation of complex division and multiplication using a call to
465     ///  runtime library functions(generally the case, but the BE might
466     /// sometimes replace the library call if it knows enough about the
467     /// potential range of the inputs). Overflow and non-finite values are
468     /// handled by the library implementation. This is the default value.
469     CX_Full,
470 
471     /// Implementation of complex division offering an improved handling
472     /// for overflow in intermediate calculations with no special handling for
473     /// NaN and infinite values.
474     CX_Improved,
475 
476     /// Implementation of complex division using algebraic formulas at
477     /// higher precision. Overflow is handled. Non-finite values are handled in
478     /// some cases. If the target hardware does not have native support for a
479     /// higher precision data type, an implementation for the complex operation
480     /// will be used to provide improved guards against intermediate overflow,
481     /// but overflow and underflow may still occur in some cases. NaN and
482     /// infinite values are not handled.
483     CX_Promoted,
484 
485     /// Implementation of complex division and multiplication using
486     /// algebraic formulas at source precision. No special handling to avoid
487     /// overflow. NaN and infinite values are not handled.
488     CX_Basic,
489 
490     /// No range rule is enabled.
491     CX_None
492   };
493 
494   /// Controls which variables have static destructors registered.
495   enum class RegisterStaticDestructorsKind {
496     /// Register static destructors for all variables.
497     All,
498     /// Register static destructors only for thread-local variables.
499     ThreadLocal,
500     /// Don't register static destructors for any variables.
501     None,
502   };
503 
504   // Define simple language options (with no accessors).
505 #define LANGOPT(Name, Bits, Default, Compatibility, Description)               \
506   unsigned Name : Bits;
507 #define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description)
508 #include "clang/Basic/LangOptions.def"
509 
510 protected:
511   // Define language options of enumeration type. These are private, and will
512   // have accessors (below).
513 #define LANGOPT(Name, Bits, Default, Compatibility, Description)
514 #define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description)    \
515   LLVM_PREFERRED_TYPE(Type)                                                    \
516   unsigned Name : Bits;
517 #include "clang/Basic/LangOptions.def"
518 };
519 
520 /// Keeps track of the various options that can be
521 /// enabled, which controls the dialect of C or C++ that is accepted.
522 class LangOptions : public LangOptionsBase {
523 public:
524   /// The used language standard.
525   LangStandard::Kind LangStd;
526 
527   /// Set of enabled sanitizers.
528   SanitizerSet Sanitize;
529   /// Is at least one coverage instrumentation type enabled.
530   bool SanitizeCoverage = false;
531 
532   /// Paths to files specifying which objects
533   /// (files, functions, variables) should not be instrumented.
534   std::vector<std::string> NoSanitizeFiles;
535 
536   /// Paths to the XRay "always instrument" files specifying which
537   /// objects (files, functions, variables) should be imbued with the XRay
538   /// "always instrument" attribute.
539   /// WARNING: This is a deprecated field and will go away in the future.
540   std::vector<std::string> XRayAlwaysInstrumentFiles;
541 
542   /// Paths to the XRay "never instrument" files specifying which
543   /// objects (files, functions, variables) should be imbued with the XRay
544   /// "never instrument" attribute.
545   /// WARNING: This is a deprecated field and will go away in the future.
546   std::vector<std::string> XRayNeverInstrumentFiles;
547 
548   /// Paths to the XRay attribute list files, specifying which objects
549   /// (files, functions, variables) should be imbued with the appropriate XRay
550   /// attribute(s).
551   std::vector<std::string> XRayAttrListFiles;
552 
553   /// Paths to special case list files specifying which entities
554   /// (files, functions) should or should not be instrumented.
555   std::vector<std::string> ProfileListFiles;
556 
557   clang::ObjCRuntime ObjCRuntime;
558 
559   CoreFoundationABI CFRuntime = CoreFoundationABI::Unspecified;
560 
561   std::string ObjCConstantStringClass;
562 
563   /// The name of the handler function to be called when -ftrapv is
564   /// specified.
565   ///
566   /// If none is specified, abort (GCC-compatible behaviour).
567   std::string OverflowHandler;
568 
569   /// The module currently being compiled as specified by -fmodule-name.
570   std::string ModuleName;
571 
572   /// The name of the current module, of which the main source file
573   /// is a part. If CompilingModule is set, we are compiling the interface
574   /// of this module, otherwise we are compiling an implementation file of
575   /// it. This starts as ModuleName in case -fmodule-name is provided and
576   /// changes during compilation to reflect the current module.
577   std::string CurrentModule;
578 
579   /// The names of any features to enable in module 'requires' decls
580   /// in addition to the hard-coded list in Module.cpp and the target features.
581   ///
582   /// This list is sorted.
583   std::vector<std::string> ModuleFeatures;
584 
585   /// Options for parsing comments.
586   CommentOptions CommentOpts;
587 
588   /// A list of all -fno-builtin-* function names (e.g., memset).
589   std::vector<std::string> NoBuiltinFuncs;
590 
591   /// A prefix map for __FILE__, __BASE_FILE__ and __builtin_FILE().
592   std::map<std::string, std::string, std::greater<std::string>> MacroPrefixMap;
593 
594   /// Triples of the OpenMP targets that the host code codegen should
595   /// take into account in order to generate accurate offloading descriptors.
596   std::vector<llvm::Triple> OMPTargetTriples;
597 
598   /// Name of the IR file that contains the result of the OpenMP target
599   /// host code generation.
600   std::string OMPHostIRFile;
601 
602   /// The user provided compilation unit ID, if non-empty. This is used to
603   /// externalize static variables which is needed to support accessing static
604   /// device variables in host code for single source offloading languages
605   /// like CUDA/HIP.
606   std::string CUID;
607 
608   /// C++ ABI to compile with, if specified by the frontend through -fc++-abi=.
609   /// This overrides the default ABI used by the target.
610   std::optional<TargetCXXABI::Kind> CXXABI;
611 
612   /// Indicates whether the front-end is explicitly told that the
613   /// input is a header file (i.e. -x c-header).
614   bool IsHeaderFile = false;
615 
616   /// The default stream kind used for HIP kernel launching.
617   GPUDefaultStreamKind GPUDefaultStream;
618 
619   /// Which overflow patterns should be excluded from sanitizer instrumentation
620   unsigned OverflowPatternExclusionMask = 0;
621 
622   std::vector<std::string> OverflowPatternExclusionValues;
623 
624   /// The seed used by the randomize structure layout feature.
625   std::string RandstructSeed;
626 
627   /// Indicates whether to use target's platform-specific file separator when
628   /// __FILE__ macro is used and when concatenating filename with directory or
629   /// to use build environment environment's platform-specific file separator.
630   ///
631   /// The plaform-specific path separator is the backslash(\) for Windows and
632   /// forward slash (/) elsewhere.
633   bool UseTargetPathSeparator = false;
634 
635   // Indicates whether we should keep all nullptr checks for pointers
636   // received as a result of a standard operator new (-fcheck-new)
637   bool CheckNew = false;
638 
639   // In OpenACC mode, contains a user provided override for the _OPENACC macro.
640   // This exists so that we can override the macro value and test our incomplete
641   // implementation on real-world examples.
642   std::string OpenACCMacroOverride;
643 
644   /// The HLSL root signature version for dxil.
645   llvm::dxbc::RootSignatureVersion HLSLRootSigVer =
646       llvm::dxbc::RootSignatureVersion::V1_1;
647 
648   // Indicates if the wasm-opt binary must be ignored in the case of a
649   // WebAssembly target.
650   bool NoWasmOpt = false;
651 
652   /// Atomic code-generation options.
653   /// These flags are set directly from the command-line options.
654   bool AtomicRemoteMemory = false;
655   bool AtomicFineGrainedMemory = false;
656   bool AtomicIgnoreDenormalMode = false;
657 
658   LangOptions();
659 
660   /// Set language defaults for the given input language and
661   /// language standard in the given LangOptions object.
662   ///
663   /// \param Opts - The LangOptions object to set up.
664   /// \param Lang - The input language.
665   /// \param T - The target triple.
666   /// \param Includes - If the language requires extra headers to be implicitly
667   ///                   included, they will be appended to this list.
668   /// \param LangStd - The input language standard.
669   static void
670   setLangDefaults(LangOptions &Opts, Language Lang, const llvm::Triple &T,
671                   std::vector<std::string> &Includes,
672                   LangStandard::Kind LangStd = LangStandard::lang_unspecified);
673 
674   // Define accessors/mutators for language options of enumeration type.
675 #define LANGOPT(Name, Bits, Default, Compatibility, Description)
676 #define ENUM_LANGOPT(Name, Type, Bits, Default, Compatibility, Description)    \
677   Type get##Name() const { return static_cast<Type>(Name); }                   \
678   void set##Name(Type Value) {                                                 \
679     assert(static_cast<unsigned>(Value) < (1u << Bits));                       \
680     Name = static_cast<unsigned>(Value);                                       \
681   }
682 #include "clang/Basic/LangOptions.def"
683 
684   /// Are we compiling a module?
isCompilingModule()685   bool isCompilingModule() const {
686     return getCompilingModule() != CMK_None;
687   }
688 
689   /// Are we compiling a module implementation?
isCompilingModuleImplementation()690   bool isCompilingModuleImplementation() const {
691     return !isCompilingModule() && !ModuleName.empty();
692   }
693 
694   /// Do we need to track the owning module for a local declaration?
trackLocalOwningModule()695   bool trackLocalOwningModule() const {
696     return isCompilingModule() || ModulesLocalVisibility;
697   }
698 
isSignedOverflowDefined()699   bool isSignedOverflowDefined() const {
700     return getSignedOverflowBehavior() == SOB_Defined;
701   }
702 
isSubscriptPointerArithmetic()703   bool isSubscriptPointerArithmetic() const {
704     return ObjCRuntime.isSubscriptPointerArithmetic() &&
705            !ObjCSubscriptingLegacyRuntime;
706   }
707 
isCompatibleWithMSVC(MSVCMajorVersion MajorVersion)708   bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
709     return MSCompatibilityVersion >= MajorVersion * 100000U;
710   }
711 
isOverflowPatternExcluded(OverflowPatternExclusionKind Kind)712   bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const {
713     if (OverflowPatternExclusionMask & OverflowPatternExclusionKind::None)
714       return false;
715     if (OverflowPatternExclusionMask & OverflowPatternExclusionKind::All)
716       return true;
717     return OverflowPatternExclusionMask & Kind;
718   }
719 
720   /// Reset all of the options that are not considered when building a
721   /// module.
722   void resetNonModularOptions();
723 
724   /// Is this a libc/libm function that is no longer recognized as a
725   /// builtin because a -fno-builtin-* option has been specified?
726   bool isNoBuiltinFunc(StringRef Name) const;
727 
728   /// True if any ObjC types may have non-trivial lifetime qualifiers.
allowsNonTrivialObjCLifetimeQualifiers()729   bool allowsNonTrivialObjCLifetimeQualifiers() const {
730     return ObjCAutoRefCount || ObjCWeak;
731   }
732 
assumeFunctionsAreConvergent()733   bool assumeFunctionsAreConvergent() const {
734     return ConvergentFunctions;
735   }
736 
737   /// Return true if atomicrmw operations targeting allocations in private
738   /// memory are undefined.
threadPrivateMemoryAtomicsAreUndefined()739   bool threadPrivateMemoryAtomicsAreUndefined() const {
740     // Should be false for OpenMP.
741     // TODO: Should this be true for SYCL?
742     return OpenCL || CUDA;
743   }
744 
745   /// Return the OpenCL C or C++ version as a VersionTuple.
746   VersionTuple getOpenCLVersionTuple() const;
747 
748   /// Return the OpenCL version that kernel language is compatible with
749   unsigned getOpenCLCompatibleVersion() const;
750 
751   /// Return the OpenCL C or C++ for OpenCL language name and version
752   /// as a string.
753   std::string getOpenCLVersionString() const;
754 
755   /// Returns true if functions without prototypes or functions with an
756   /// identifier list (aka K&R C functions) are not allowed.
requiresStrictPrototypes()757   bool requiresStrictPrototypes() const {
758     return CPlusPlus || C23 || DisableKNRFunctions;
759   }
760 
761   /// Returns true if implicit function declarations are allowed in the current
762   /// language mode.
implicitFunctionsAllowed()763   bool implicitFunctionsAllowed() const {
764     return !requiresStrictPrototypes() && !OpenCL;
765   }
766 
767   /// Returns true if the language supports calling the 'atexit' function.
hasAtExit()768   bool hasAtExit() const { return !(OpenMP && OpenMPIsTargetDevice); }
769 
770   /// Returns true if implicit int is part of the language requirements.
isImplicitIntRequired()771   bool isImplicitIntRequired() const { return !CPlusPlus && !C99; }
772 
773   /// Returns true if implicit int is supported at all.
isImplicitIntAllowed()774   bool isImplicitIntAllowed() const { return !CPlusPlus && !C23; }
775 
776   /// Check if return address signing is enabled.
hasSignReturnAddress()777   bool hasSignReturnAddress() const {
778     return getSignReturnAddressScope() != SignReturnAddressScopeKind::None;
779   }
780 
781   /// Check if return address signing uses AKey.
isSignReturnAddressWithAKey()782   bool isSignReturnAddressWithAKey() const {
783     return getSignReturnAddressKey() == SignReturnAddressKeyKind::AKey;
784   }
785 
786   /// Check if leaf functions are also signed.
isSignReturnAddressScopeAll()787   bool isSignReturnAddressScopeAll() const {
788     return getSignReturnAddressScope() == SignReturnAddressScopeKind::All;
789   }
790 
hasSjLjExceptions()791   bool hasSjLjExceptions() const {
792     return getExceptionHandling() == ExceptionHandlingKind::SjLj;
793   }
794 
hasSEHExceptions()795   bool hasSEHExceptions() const {
796     return getExceptionHandling() == ExceptionHandlingKind::WinEH;
797   }
798 
hasDWARFExceptions()799   bool hasDWARFExceptions() const {
800     return getExceptionHandling() == ExceptionHandlingKind::DwarfCFI;
801   }
802 
hasWasmExceptions()803   bool hasWasmExceptions() const {
804     return getExceptionHandling() == ExceptionHandlingKind::Wasm;
805   }
806 
isSYCL()807   bool isSYCL() const { return SYCLIsDevice || SYCLIsHost; }
808 
hasDefaultVisibilityExportMapping()809   bool hasDefaultVisibilityExportMapping() const {
810     return getDefaultVisibilityExportMapping() !=
811            DefaultVisiblityExportMapping::None;
812   }
813 
isExplicitDefaultVisibilityExportMapping()814   bool isExplicitDefaultVisibilityExportMapping() const {
815     return getDefaultVisibilityExportMapping() ==
816            DefaultVisiblityExportMapping::Explicit;
817   }
818 
isAllDefaultVisibilityExportMapping()819   bool isAllDefaultVisibilityExportMapping() const {
820     return getDefaultVisibilityExportMapping() ==
821            DefaultVisiblityExportMapping::All;
822   }
823 
hasGlobalAllocationFunctionVisibility()824   bool hasGlobalAllocationFunctionVisibility() const {
825     return getGlobalAllocationFunctionVisibility() !=
826            VisibilityForcedKinds::Source;
827   }
828 
hasDefaultGlobalAllocationFunctionVisibility()829   bool hasDefaultGlobalAllocationFunctionVisibility() const {
830     return getGlobalAllocationFunctionVisibility() ==
831            VisibilityForcedKinds::ForceDefault;
832   }
833 
hasProtectedGlobalAllocationFunctionVisibility()834   bool hasProtectedGlobalAllocationFunctionVisibility() const {
835     return getGlobalAllocationFunctionVisibility() ==
836            VisibilityForcedKinds::ForceProtected;
837   }
838 
hasHiddenGlobalAllocationFunctionVisibility()839   bool hasHiddenGlobalAllocationFunctionVisibility() const {
840     return getGlobalAllocationFunctionVisibility() ==
841            VisibilityForcedKinds::ForceHidden;
842   }
843 
allowArrayReturnTypes()844   bool allowArrayReturnTypes() const { return HLSL; }
845 
846   /// Remap path prefix according to -fmacro-prefix-path option.
847   void remapPathPrefix(SmallVectorImpl<char> &Path) const;
848 
getDefaultRoundingMode()849   RoundingMode getDefaultRoundingMode() const {
850     return RoundingMath ? RoundingMode::Dynamic
851                         : RoundingMode::NearestTiesToEven;
852   }
853 
getDefaultExceptionMode()854   FPExceptionModeKind getDefaultExceptionMode() const {
855     FPExceptionModeKind EM = getFPExceptionMode();
856     if (EM == FPExceptionModeKind::FPE_Default)
857       return FPExceptionModeKind::FPE_Ignore;
858     return EM;
859   }
860 
861   /// True when compiling for an offloading target device.
isTargetDevice()862   bool isTargetDevice() const {
863     return OpenMPIsTargetDevice || CUDAIsDevice || SYCLIsDevice;
864   }
865 };
866 
867 /// Floating point control options
868 class FPOptionsOverride;
869 class FPOptions {
870 public:
871   // We start by defining the layout.
872   using storage_type = uint32_t;
873 
874   using RoundingMode = llvm::RoundingMode;
875 
876   static constexpr unsigned StorageBitSize = 8 * sizeof(storage_type);
877 
878   // Define a fake option named "First" so that we have a PREVIOUS even for the
879   // real first option.
880   static constexpr storage_type FirstShift = 0, FirstWidth = 0;
881 #define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                 \
882   static constexpr storage_type NAME##Shift =                                  \
883       PREVIOUS##Shift + PREVIOUS##Width;                                       \
884   static constexpr storage_type NAME##Width = WIDTH;                           \
885   static constexpr storage_type NAME##Mask = ((1 << NAME##Width) - 1)          \
886                                              << NAME##Shift;
887 #include "clang/Basic/FPOptions.def"
888 
889   static constexpr storage_type TotalWidth = 0
890 #define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS) +WIDTH
891 #include "clang/Basic/FPOptions.def"
892       ;
893   static_assert(TotalWidth <= StorageBitSize, "Too short type for FPOptions");
894 
895 private:
896   storage_type Value;
897 
898   FPOptionsOverride getChangesSlow(const FPOptions &Base) const;
899 
900 public:
FPOptions()901   FPOptions() : Value(0) {
902     setFPContractMode(LangOptions::FPM_Off);
903     setConstRoundingMode(RoundingMode::Dynamic);
904     setSpecifiedExceptionMode(LangOptions::FPE_Default);
905   }
FPOptions(const LangOptions & LO)906   explicit FPOptions(const LangOptions &LO) {
907     Value = 0;
908     // The language fp contract option FPM_FastHonorPragmas has the same effect
909     // as FPM_Fast in frontend. For simplicity, use FPM_Fast uniformly in
910     // frontend.
911     auto LangOptContractMode = LO.getDefaultFPContractMode();
912     if (LangOptContractMode == LangOptions::FPM_FastHonorPragmas)
913       LangOptContractMode = LangOptions::FPM_Fast;
914     setFPContractMode(LangOptContractMode);
915     setRoundingMath(LO.RoundingMath);
916     setConstRoundingMode(LangOptions::RoundingMode::Dynamic);
917     setSpecifiedExceptionMode(LO.getFPExceptionMode());
918     setAllowFPReassociate(LO.AllowFPReassoc);
919     setNoHonorNaNs(LO.NoHonorNaNs);
920     setNoHonorInfs(LO.NoHonorInfs);
921     setNoSignedZero(LO.NoSignedZero);
922     setAllowReciprocal(LO.AllowRecip);
923     setAllowApproxFunc(LO.ApproxFunc);
924     if (getFPContractMode() == LangOptions::FPM_On &&
925         getRoundingMode() == llvm::RoundingMode::Dynamic &&
926         getExceptionMode() == LangOptions::FPE_Strict)
927       // If the FP settings are set to the "strict" model, then
928       // FENV access is set to true. (ffp-model=strict)
929       setAllowFEnvAccess(true);
930     else
931       setAllowFEnvAccess(LangOptions::FPM_Off);
932     setComplexRange(LO.getComplexRange());
933   }
934 
allowFPContractWithinStatement()935   bool allowFPContractWithinStatement() const {
936     return getFPContractMode() == LangOptions::FPM_On;
937   }
setAllowFPContractWithinStatement()938   void setAllowFPContractWithinStatement() {
939     setFPContractMode(LangOptions::FPM_On);
940   }
941 
allowFPContractAcrossStatement()942   bool allowFPContractAcrossStatement() const {
943     return getFPContractMode() == LangOptions::FPM_Fast;
944   }
setAllowFPContractAcrossStatement()945   void setAllowFPContractAcrossStatement() {
946     setFPContractMode(LangOptions::FPM_Fast);
947   }
948 
isFPConstrained()949   bool isFPConstrained() const {
950     return getRoundingMode() != llvm::RoundingMode::NearestTiesToEven ||
951            getExceptionMode() != LangOptions::FPE_Ignore ||
952            getAllowFEnvAccess();
953   }
954 
getRoundingMode()955   RoundingMode getRoundingMode() const {
956     RoundingMode RM = getConstRoundingMode();
957     if (RM == RoundingMode::Dynamic) {
958       // C23: 7.6.2p3  If the FE_DYNAMIC mode is specified and FENV_ACCESS is
959       // "off", the translator may assume that the default rounding mode is in
960       // effect.
961       if (!getAllowFEnvAccess() && !getRoundingMath())
962         RM = RoundingMode::NearestTiesToEven;
963     }
964     return RM;
965   }
966 
getExceptionMode()967   LangOptions::FPExceptionModeKind getExceptionMode() const {
968     LangOptions::FPExceptionModeKind EM = getSpecifiedExceptionMode();
969     if (EM == LangOptions::FPExceptionModeKind::FPE_Default) {
970       if (getAllowFEnvAccess())
971         return LangOptions::FPExceptionModeKind::FPE_Strict;
972       else
973         return LangOptions::FPExceptionModeKind::FPE_Ignore;
974     }
975     return EM;
976   }
977 
978   bool operator==(FPOptions other) const { return Value == other.Value; }
979 
980   /// Return the default value of FPOptions that's used when trailing
981   /// storage isn't required.
982   static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO);
983 
getAsOpaqueInt()984   storage_type getAsOpaqueInt() const { return Value; }
getFromOpaqueInt(storage_type Value)985   static FPOptions getFromOpaqueInt(storage_type Value) {
986     FPOptions Opts;
987     Opts.Value = Value;
988     return Opts;
989   }
990 
991   /// Return difference with the given option set.
992   FPOptionsOverride getChangesFrom(const FPOptions &Base) const;
993 
994   void applyChanges(FPOptionsOverride FPO);
995 
996   // We can define most of the accessors automatically:
997   // TODO: consider enforcing the assertion that value fits within bits
998   // statically.
999 #define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                 \
1000   TYPE get##NAME() const {                                                     \
1001     return static_cast<TYPE>((Value & NAME##Mask) >> NAME##Shift);             \
1002   }                                                                            \
1003   void set##NAME(TYPE value) {                                                 \
1004     assert(storage_type(value) < (1u << WIDTH));                               \
1005     Value = (Value & ~NAME##Mask) | (storage_type(value) << NAME##Shift);      \
1006   }
1007 #include "clang/Basic/FPOptions.def"
1008   LLVM_DUMP_METHOD void dump();
1009 };
1010 
1011 /// Represents difference between two FPOptions values.
1012 ///
1013 /// The effect of language constructs changing the set of floating point options
1014 /// is usually a change of some FP properties while leaving others intact. This
1015 /// class describes such changes by keeping information about what FP options
1016 /// are overridden.
1017 ///
1018 /// The integral set of FP options, described by the class FPOptions, may be
1019 /// represented as a default FP option set, defined by language standard and
1020 /// command line options, with the overrides introduced by pragmas.
1021 ///
1022 /// The is implemented as a value of the new FPOptions plus a mask showing which
1023 /// fields are actually set in it.
1024 class FPOptionsOverride {
1025   FPOptions Options = FPOptions::getFromOpaqueInt(0);
1026   FPOptions::storage_type OverrideMask = 0;
1027 
1028 public:
1029   using RoundingMode = llvm::RoundingMode;
1030 
1031   /// The type suitable for storing values of FPOptionsOverride. Must be twice
1032   /// as wide as bit size of FPOption.
1033   using storage_type = uint64_t;
1034   static_assert(sizeof(storage_type) >= 2 * sizeof(FPOptions::storage_type),
1035                 "Too short type for FPOptionsOverride");
1036 
1037   /// Bit mask selecting bits of OverrideMask in serialized representation of
1038   /// FPOptionsOverride.
1039   static constexpr storage_type OverrideMaskBits =
1040       (static_cast<storage_type>(1) << FPOptions::StorageBitSize) - 1;
1041 
FPOptionsOverride()1042   FPOptionsOverride() {}
FPOptionsOverride(const LangOptions & LO)1043   FPOptionsOverride(const LangOptions &LO)
1044       : Options(LO), OverrideMask(OverrideMaskBits) {}
FPOptionsOverride(FPOptions FPO)1045   FPOptionsOverride(FPOptions FPO)
1046       : Options(FPO), OverrideMask(OverrideMaskBits) {}
FPOptionsOverride(FPOptions FPO,FPOptions::storage_type Mask)1047   FPOptionsOverride(FPOptions FPO, FPOptions::storage_type Mask)
1048       : Options(FPO), OverrideMask(Mask) {}
1049 
requiresTrailingStorage()1050   bool requiresTrailingStorage() const { return OverrideMask != 0; }
1051 
setAllowFPContractWithinStatement()1052   void setAllowFPContractWithinStatement() {
1053     setFPContractModeOverride(LangOptions::FPM_On);
1054   }
1055 
setAllowFPContractAcrossStatement()1056   void setAllowFPContractAcrossStatement() {
1057     setFPContractModeOverride(LangOptions::FPM_Fast);
1058   }
1059 
setDisallowFPContract()1060   void setDisallowFPContract() {
1061     setFPContractModeOverride(LangOptions::FPM_Off);
1062   }
1063 
setFPPreciseEnabled(bool Value)1064   void setFPPreciseEnabled(bool Value) {
1065     setAllowFPReassociateOverride(!Value);
1066     setNoHonorNaNsOverride(!Value);
1067     setNoHonorInfsOverride(!Value);
1068     setNoSignedZeroOverride(!Value);
1069     setAllowReciprocalOverride(!Value);
1070     setAllowApproxFuncOverride(!Value);
1071     setMathErrnoOverride(Value);
1072     if (Value)
1073       /* Precise mode implies fp_contract=on and disables ffast-math */
1074       setAllowFPContractWithinStatement();
1075     else
1076       /* Precise mode disabled sets fp_contract=fast and enables ffast-math */
1077       setAllowFPContractAcrossStatement();
1078   }
1079 
setDisallowOptimizations()1080   void setDisallowOptimizations() { setFPPreciseEnabled(true); }
1081 
getAsOpaqueInt()1082   storage_type getAsOpaqueInt() const {
1083     return (static_cast<storage_type>(Options.getAsOpaqueInt())
1084             << FPOptions::StorageBitSize) |
1085            OverrideMask;
1086   }
getFromOpaqueInt(storage_type I)1087   static FPOptionsOverride getFromOpaqueInt(storage_type I) {
1088     FPOptionsOverride Opts;
1089     Opts.OverrideMask = I & OverrideMaskBits;
1090     Opts.Options = FPOptions::getFromOpaqueInt(I >> FPOptions::StorageBitSize);
1091     return Opts;
1092   }
1093 
applyOverrides(FPOptions Base)1094   FPOptions applyOverrides(FPOptions Base) {
1095     FPOptions Result =
1096         FPOptions::getFromOpaqueInt((Base.getAsOpaqueInt() & ~OverrideMask) |
1097                                      (Options.getAsOpaqueInt() & OverrideMask));
1098     return Result;
1099   }
1100 
applyOverrides(const LangOptions & LO)1101   FPOptions applyOverrides(const LangOptions &LO) {
1102     return applyOverrides(FPOptions(LO));
1103   }
1104 
1105   bool operator==(FPOptionsOverride other) const {
1106     return Options == other.Options && OverrideMask == other.OverrideMask;
1107   }
1108   bool operator!=(FPOptionsOverride other) const { return !(*this == other); }
1109 
1110 #define FP_OPTION(NAME, TYPE, WIDTH, PREVIOUS)                                 \
1111   bool has##NAME##Override() const {                                           \
1112     return OverrideMask & FPOptions::NAME##Mask;                               \
1113   }                                                                            \
1114   TYPE get##NAME##Override() const {                                           \
1115     assert(has##NAME##Override());                                             \
1116     return Options.get##NAME();                                                \
1117   }                                                                            \
1118   void clear##NAME##Override() {                                               \
1119     /* Clear the actual value so that we don't have spurious differences when  \
1120      * testing equality. */                                                    \
1121     Options.set##NAME(TYPE(0));                                                \
1122     OverrideMask &= ~FPOptions::NAME##Mask;                                    \
1123   }                                                                            \
1124   void set##NAME##Override(TYPE value) {                                       \
1125     Options.set##NAME(value);                                                  \
1126     OverrideMask |= FPOptions::NAME##Mask;                                     \
1127   }
1128 #include "clang/Basic/FPOptions.def"
1129   LLVM_DUMP_METHOD void dump();
1130 };
1131 
getChangesFrom(const FPOptions & Base)1132 inline FPOptionsOverride FPOptions::getChangesFrom(const FPOptions &Base) const {
1133   if (Value == Base.Value)
1134     return FPOptionsOverride();
1135   return getChangesSlow(Base);
1136 }
1137 
applyChanges(FPOptionsOverride FPO)1138 inline void FPOptions::applyChanges(FPOptionsOverride FPO) {
1139   *this = FPO.applyOverrides(*this);
1140 }
1141 
1142 // The three atomic code-generation options.
1143 // The canonical (positive) names are:
1144 //   "remote_memory", "fine_grained_memory", and "ignore_denormal_mode".
1145 // In attribute or command-line parsing, a token prefixed with "no_" inverts its
1146 // value.
1147 enum class AtomicOptionKind {
1148   RemoteMemory,       // enable remote memory.
1149   FineGrainedMemory,  // enable fine-grained memory.
1150   IgnoreDenormalMode, // ignore floating-point denormals.
1151   LANGOPT_ATOMIC_OPTION_LAST = IgnoreDenormalMode,
1152 };
1153 
1154 struct AtomicOptions {
1155   // Bitfields for each option.
1156   unsigned remote_memory : 1;
1157   unsigned fine_grained_memory : 1;
1158   unsigned ignore_denormal_mode : 1;
1159 
AtomicOptionsAtomicOptions1160   AtomicOptions()
1161       : remote_memory(0), fine_grained_memory(0), ignore_denormal_mode(0) {}
1162 
AtomicOptionsAtomicOptions1163   AtomicOptions(const LangOptions &LO)
1164       : remote_memory(LO.AtomicRemoteMemory),
1165         fine_grained_memory(LO.AtomicFineGrainedMemory),
1166         ignore_denormal_mode(LO.AtomicIgnoreDenormalMode) {}
1167 
getOptionAtomicOptions1168   bool getOption(AtomicOptionKind Kind) const {
1169     switch (Kind) {
1170     case AtomicOptionKind::RemoteMemory:
1171       return remote_memory;
1172     case AtomicOptionKind::FineGrainedMemory:
1173       return fine_grained_memory;
1174     case AtomicOptionKind::IgnoreDenormalMode:
1175       return ignore_denormal_mode;
1176     }
1177     llvm_unreachable("Invalid AtomicOptionKind");
1178   }
1179 
setOptionAtomicOptions1180   void setOption(AtomicOptionKind Kind, bool Value) {
1181     switch (Kind) {
1182     case AtomicOptionKind::RemoteMemory:
1183       remote_memory = Value;
1184       return;
1185     case AtomicOptionKind::FineGrainedMemory:
1186       fine_grained_memory = Value;
1187       return;
1188     case AtomicOptionKind::IgnoreDenormalMode:
1189       ignore_denormal_mode = Value;
1190       return;
1191     }
1192     llvm_unreachable("Invalid AtomicOptionKind");
1193   }
1194 
dumpAtomicOptions1195   LLVM_DUMP_METHOD void dump() const {
1196     llvm::errs() << "\n remote_memory: " << remote_memory
1197                  << "\n fine_grained_memory: " << fine_grained_memory
1198                  << "\n ignore_denormal_mode: " << ignore_denormal_mode << "\n";
1199   }
1200 };
1201 
1202 /// Describes the kind of translation unit being processed.
1203 enum TranslationUnitKind {
1204   /// The translation unit is a complete translation unit.
1205   TU_Complete,
1206 
1207   /// The translation unit is a prefix to a translation unit, and is
1208   /// not complete.
1209   TU_Prefix,
1210 
1211   /// The translation unit is a clang module.
1212   TU_ClangModule,
1213 
1214   /// The translation unit is a is a complete translation unit that we might
1215   /// incrementally extend later.
1216   TU_Incremental
1217 };
1218 
1219 } // namespace clang
1220 
1221 #endif // LLVM_CLANG_BASIC_LANGOPTIONS_H
1222