1 //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines the clang::LangOptions interface.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_LANGOPTIONS_H
16 #define LLVM_CLANG_LANGOPTIONS_H
19 #include "clang/Basic/LLVM.h"
20 #include "clang/Basic/ObjCRuntime.h"
21 #include "clang/Basic/Visibility.h"
22 #include "llvm/ADT/IntrusiveRefCntPtr.h"
26 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
27 /// this large collection of bitfields is a trivial class type.
28 class LangOptionsBase {
30 // Define simple language options (with no accessors).
31 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
32 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
33 #include "clang/Basic/LangOptions.def"
36 // Define language options of enumeration type. These are private, and will
37 // have accessors (below).
38 #define LANGOPT(Name, Bits, Default, Description)
39 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
41 #include "clang/Basic/LangOptions.def"
44 /// \brief Keeps track of the various options that can be
45 /// enabled, which controls the dialect of C or C++ that is accepted.
46 class LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase {
48 typedef clang::Visibility Visibility;
50 enum GCMode { NonGC, GCOnly, HybridGC };
51 enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
53 enum SignedOverflowBehaviorTy {
54 SOB_Undefined, // Default C standard behavior.
55 SOB_Defined, // -fwrapv
56 SOB_Trapping // -ftrapv
59 enum FPContractModeKind {
60 FPC_Off, // Form fused FP ops only where result will not be affected.
61 FPC_On, // Form fused FP ops according to FP_CONTRACT rules.
62 FPC_Fast // Aggressively fuse FP ops (E.g. FMA).
66 clang::ObjCRuntime ObjCRuntime;
68 std::string ObjCConstantStringClass;
70 /// \brief The name of the handler function to be called when -ftrapv is
73 /// If none is specified, abort (GCC-compatible behaviour).
74 std::string OverflowHandler;
76 /// \brief The name of the current module.
77 std::string CurrentModule;
81 // Define accessors/mutators for language options of enumeration type.
82 #define LANGOPT(Name, Bits, Default, Description)
83 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
84 Type get##Name() const { return static_cast<Type>(Name); } \
85 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
86 #include "clang/Basic/LangOptions.def"
88 bool isSignedOverflowDefined() const {
89 return getSignedOverflowBehavior() == SOB_Defined;
92 /// \brief Reset all of the options that are not considered when building a
94 void resetNonModularOptions();
97 /// \brief Floating point control options
100 unsigned fp_contract : 1;
102 FPOptions() : fp_contract(0) {}
104 FPOptions(const LangOptions &LangOpts) :
105 fp_contract(LangOpts.DefaultFPContract) {}
108 /// \brief OpenCL volatile options
109 class OpenCLOptions {
111 #define OPENCLEXT(nm) unsigned nm : 1;
112 #include "clang/Basic/OpenCLExtensions.def"
115 #define OPENCLEXT(nm) nm = 0;
116 #include "clang/Basic/OpenCLExtensions.def"
120 /// \brief Describes the kind of translation unit being processed.
121 enum TranslationUnitKind {
122 /// \brief The translation unit is a complete translation unit.
124 /// \brief The translation unit is a prefix to a translation unit, and is
127 /// \brief The translation unit is a module.
131 } // end namespace clang