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_BASIC_LANGOPTIONS_H
16 #define LLVM_CLANG_BASIC_LANGOPTIONS_H
18 #include "clang/Basic/CommentOptions.h"
19 #include "clang/Basic/LLVM.h"
20 #include "clang/Basic/ObjCRuntime.h"
21 #include "clang/Basic/Sanitizers.h"
22 #include "clang/Basic/Visibility.h"
28 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
29 /// this large collection of bitfields is a trivial class type.
30 class LangOptionsBase {
32 // Define simple language options (with no accessors).
33 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
34 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
35 #include "clang/Basic/LangOptions.def"
38 // Define language options of enumeration type. These are private, and will
39 // have accessors (below).
40 #define LANGOPT(Name, Bits, Default, Description)
41 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
43 #include "clang/Basic/LangOptions.def"
46 /// \brief Keeps track of the various options that can be
47 /// enabled, which controls the dialect of C or C++ that is accepted.
48 class LangOptions : public LangOptionsBase {
50 typedef clang::Visibility Visibility;
52 enum GCMode { NonGC, GCOnly, HybridGC };
53 enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
55 enum SignedOverflowBehaviorTy {
56 SOB_Undefined, // Default C standard behavior.
57 SOB_Defined, // -fwrapv
58 SOB_Trapping // -ftrapv
61 enum PragmaMSPointersToMembersKind {
63 PPTMK_FullGeneralitySingleInheritance,
64 PPTMK_FullGeneralityMultipleInheritance,
65 PPTMK_FullGeneralityVirtualInheritance
68 enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
70 enum MSVCMajorVersion {
78 /// \brief Set of enabled sanitizers.
79 SanitizerSet Sanitize;
81 /// \brief Paths to blacklist files specifying which objects
82 /// (files, functions, variables) should not be instrumented.
83 std::vector<std::string> SanitizerBlacklistFiles;
85 clang::ObjCRuntime ObjCRuntime;
87 std::string ObjCConstantStringClass;
89 /// \brief The name of the handler function to be called when -ftrapv is
92 /// If none is specified, abort (GCC-compatible behaviour).
93 std::string OverflowHandler;
95 /// \brief The name of the current module.
96 std::string CurrentModule;
98 /// \brief The name of the module that the translation unit is an
99 /// implementation of. Prevents semantic imports, but does not otherwise
100 /// treat this as the CurrentModule.
101 std::string ImplementationOfModule;
103 /// \brief The names of any features to enable in module 'requires' decls
104 /// in addition to the hard-coded list in Module.cpp and the target features.
106 /// This list is sorted.
107 std::vector<std::string> ModuleFeatures;
109 /// \brief Options for parsing comments.
110 CommentOptions CommentOpts;
112 /// \brief A list of all -fno-builtin-* function names (e.g., memset).
113 std::vector<std::string> NoBuiltinFuncs;
115 /// \brief Triples of the OpenMP targets that the host code codegen should
116 /// take into account in order to generate accurate offloading descriptors.
117 std::vector<llvm::Triple> OMPTargetTriples;
119 /// \brief Name of the IR file that contains the result of the OpenMP target
120 /// host code generation.
121 std::string OMPHostIRFile;
125 // Define accessors/mutators for language options of enumeration type.
126 #define LANGOPT(Name, Bits, Default, Description)
127 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
128 Type get##Name() const { return static_cast<Type>(Name); } \
129 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
130 #include "clang/Basic/LangOptions.def"
132 bool isSignedOverflowDefined() const {
133 return getSignedOverflowBehavior() == SOB_Defined;
136 bool isSubscriptPointerArithmetic() const {
137 return ObjCRuntime.isSubscriptPointerArithmetic() &&
138 !ObjCSubscriptingLegacyRuntime;
141 bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
142 return MSCompatibilityVersion >= MajorVersion * 10000000U;
145 /// \brief Reset all of the options that are not considered when building a
147 void resetNonModularOptions();
149 /// \brief Is this a libc/libm function that is no longer recognized as a
150 /// builtin because a -fno-builtin-* option has been specified?
151 bool isNoBuiltinFunc(const char *Name) const;
154 /// \brief Floating point control options
157 unsigned fp_contract : 1;
159 FPOptions() : fp_contract(0) {}
161 FPOptions(const LangOptions &LangOpts) :
162 fp_contract(LangOpts.DefaultFPContract) {}
165 /// \brief OpenCL volatile options
166 class OpenCLOptions {
168 #define OPENCLEXT(nm) unsigned nm : 1;
169 #include "clang/Basic/OpenCLExtensions.def"
172 #define OPENCLEXT(nm) nm = 0;
173 #include "clang/Basic/OpenCLExtensions.def"
177 /// \brief Describes the kind of translation unit being processed.
178 enum TranslationUnitKind {
179 /// \brief The translation unit is a complete translation unit.
181 /// \brief The translation unit is a prefix to a translation unit, and is
184 /// \brief The translation unit is a module.
188 } // end namespace clang