]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/LangOptions.h
Merge compiler-rt r291274.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / LangOptions.h
1 //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Defines the clang::LangOptions interface.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
16 #define LLVM_CLANG_BASIC_LANGOPTIONS_H
17
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"
23 #include <string>
24 #include <vector>
25
26 namespace clang {
27
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 {
31 public:
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"
36
37 protected:
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) \
42   unsigned Name : Bits;
43 #include "clang/Basic/LangOptions.def"
44 };
45
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 {
49 public:
50   typedef clang::Visibility Visibility;
51   
52   enum GCMode { NonGC, GCOnly, HybridGC };
53   enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
54   
55   enum SignedOverflowBehaviorTy {
56     SOB_Undefined,  // Default C standard behavior.
57     SOB_Defined,    // -fwrapv
58     SOB_Trapping    // -ftrapv
59   };
60
61   enum CompilingModuleKind {
62     CMK_None,           ///< Not compiling a module interface at all.
63     CMK_ModuleMap,      ///< Compiling a module from a module map.
64     CMK_ModuleInterface ///< Compiling a C++ modules TS module interface unit.
65   };
66
67   enum PragmaMSPointersToMembersKind {
68     PPTMK_BestCase,
69     PPTMK_FullGeneralitySingleInheritance,
70     PPTMK_FullGeneralityMultipleInheritance,
71     PPTMK_FullGeneralityVirtualInheritance
72   };
73
74   enum DefaultCallingConvention {
75     DCC_None,
76     DCC_CDecl,
77     DCC_FastCall,
78     DCC_StdCall,
79     DCC_VectorCall
80   };
81
82   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
83
84   enum MSVCMajorVersion {
85     MSVC2010 = 16,
86     MSVC2012 = 17,
87     MSVC2013 = 18,
88     MSVC2015 = 19
89   };
90
91 public:
92   /// \brief Set of enabled sanitizers.
93   SanitizerSet Sanitize;
94
95   /// \brief Paths to blacklist files specifying which objects
96   /// (files, functions, variables) should not be instrumented.
97   std::vector<std::string> SanitizerBlacklistFiles;
98
99   clang::ObjCRuntime ObjCRuntime;
100
101   std::string ObjCConstantStringClass;
102   
103   /// \brief The name of the handler function to be called when -ftrapv is
104   /// specified.
105   ///
106   /// If none is specified, abort (GCC-compatible behaviour).
107   std::string OverflowHandler;
108
109   /// \brief The name of the current module, of which the main source file
110   /// is a part. If CompilingModule is set, we are compiling the interface
111   /// of this module, otherwise we are compiling an implementation file of
112   /// it.
113   std::string CurrentModule;
114
115   /// \brief The names of any features to enable in module 'requires' decls
116   /// in addition to the hard-coded list in Module.cpp and the target features.
117   ///
118   /// This list is sorted.
119   std::vector<std::string> ModuleFeatures;
120
121   /// \brief Options for parsing comments.
122   CommentOptions CommentOpts;
123
124   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
125   std::vector<std::string> NoBuiltinFuncs;
126
127   /// \brief Triples of the OpenMP targets that the host code codegen should
128   /// take into account in order to generate accurate offloading descriptors.
129   std::vector<llvm::Triple> OMPTargetTriples;
130
131   /// \brief Name of the IR file that contains the result of the OpenMP target
132   /// host code generation.
133   std::string OMPHostIRFile;
134
135   /// \brief Indicates whether the front-end is explicitly told that the
136   /// input is a header file (i.e. -x c-header).
137   bool IsHeaderFile;
138
139   LangOptions();
140
141   // Define accessors/mutators for language options of enumeration type.
142 #define LANGOPT(Name, Bits, Default, Description) 
143 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
144   Type get##Name() const { return static_cast<Type>(Name); } \
145   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
146 #include "clang/Basic/LangOptions.def"
147
148   /// Are we compiling a module interface (.cppm or module map)?
149   bool isCompilingModule() const {
150     return getCompilingModule() != CMK_None;
151   }
152
153   bool isSignedOverflowDefined() const {
154     return getSignedOverflowBehavior() == SOB_Defined;
155   }
156   
157   bool isSubscriptPointerArithmetic() const {
158     return ObjCRuntime.isSubscriptPointerArithmetic() &&
159            !ObjCSubscriptingLegacyRuntime;
160   }
161
162   bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
163     return MSCompatibilityVersion >= MajorVersion * 10000000U;
164   }
165
166   /// \brief Reset all of the options that are not considered when building a
167   /// module.
168   void resetNonModularOptions();
169
170   /// \brief Is this a libc/libm function that is no longer recognized as a
171   /// builtin because a -fno-builtin-* option has been specified?
172   bool isNoBuiltinFunc(StringRef Name) const;
173 };
174
175 /// \brief Floating point control options
176 class FPOptions {
177 public:
178   unsigned fp_contract : 1;
179
180   FPOptions() : fp_contract(0) {}
181
182   FPOptions(const LangOptions &LangOpts) :
183     fp_contract(LangOpts.DefaultFPContract) {}
184 };
185
186 /// \brief Describes the kind of translation unit being processed.
187 enum TranslationUnitKind {
188   /// \brief The translation unit is a complete translation unit.
189   TU_Complete,
190   /// \brief The translation unit is a prefix to a translation unit, and is
191   /// not complete.
192   TU_Prefix,
193   /// \brief The translation unit is a module.
194   TU_Module
195 };
196   
197 }  // end namespace clang
198
199 #endif