| 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 | |
| 17 | #include "clang/Basic/CommentOptions.h" |
| 18 | #include "clang/Basic/LLVM.h" |
| 19 | #include "clang/Basic/ObjCRuntime.h" |
| 20 | #include "clang/Basic/Sanitizers.h" |
| 21 | #include "clang/Basic/Visibility.h" |
| 22 | #include "llvm/ADT/StringRef.h" |
| 23 | #include "llvm/ADT/Triple.h" |
| 24 | #include <string> |
| 25 | #include <vector> |
| 26 | |
| 27 | namespace clang { |
| 28 | |
| 29 | |
| 30 | |
| 31 | class LangOptionsBase { |
| 32 | public: |
| 33 | |
| 34 | #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits; |
| 35 | #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) |
| 36 | #include "clang/Basic/LangOptions.def" |
| 37 | |
| 38 | protected: |
| 39 | |
| 40 | |
| 41 | #define LANGOPT(Name, Bits, Default, Description) |
| 42 | #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ |
| 43 | unsigned Name : Bits; |
| 44 | #include "clang/Basic/LangOptions.def" |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | |
| 49 | class LangOptions : public LangOptionsBase { |
| 50 | public: |
| 51 | using Visibility = clang::Visibility; |
| 52 | |
| 53 | enum GCMode { NonGC, GCOnly, HybridGC }; |
| 54 | enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq }; |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | enum class TrivialAutoVarInitKind { Uninitialized, Zero, Pattern }; |
| 60 | |
| 61 | enum SignedOverflowBehaviorTy { |
| 62 | |
| 63 | SOB_Undefined, |
| 64 | |
| 65 | |
| 66 | SOB_Defined, |
| 67 | |
| 68 | |
| 69 | SOB_Trapping |
| 70 | }; |
| 71 | |
| 72 | |
| 73 | enum CompilingModuleKind { |
| 74 | |
| 75 | CMK_None, |
| 76 | |
| 77 | |
| 78 | CMK_ModuleMap, |
| 79 | |
| 80 | |
| 81 | , |
| 82 | |
| 83 | |
| 84 | CMK_ModuleInterface, |
| 85 | }; |
| 86 | |
| 87 | enum PragmaMSPointersToMembersKind { |
| 88 | PPTMK_BestCase, |
| 89 | PPTMK_FullGeneralitySingleInheritance, |
| 90 | PPTMK_FullGeneralityMultipleInheritance, |
| 91 | PPTMK_FullGeneralityVirtualInheritance |
| 92 | }; |
| 93 | |
| 94 | enum DefaultCallingConvention { |
| 95 | DCC_None, |
| 96 | DCC_CDecl, |
| 97 | DCC_FastCall, |
| 98 | DCC_StdCall, |
| 99 | DCC_VectorCall, |
| 100 | DCC_RegCall |
| 101 | }; |
| 102 | |
| 103 | enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off }; |
| 104 | |
| 105 | |
| 106 | enum MSVCMajorVersion { |
| 107 | MSVC2010 = 1600, |
| 108 | MSVC2012 = 1700, |
| 109 | MSVC2013 = 1800, |
| 110 | MSVC2015 = 1900, |
| 111 | MSVC2017 = 1910, |
| 112 | MSVC2017_5 = 1912 |
| 113 | }; |
| 114 | |
| 115 | |
| 116 | enum class ClangABI { |
| 117 | |
| 118 | |
| 119 | |
| 120 | Ver3_8, |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | Ver4, |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | Ver6, |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | Ver7, |
| 139 | |
| 140 | |
| 141 | |
| 142 | Latest |
| 143 | }; |
| 144 | |
| 145 | enum class CoreFoundationABI { |
| 146 | |
| 147 | Unspecified, |
| 148 | |
| 149 | Standalone, |
| 150 | |
| 151 | ObjectiveC, |
| 152 | |
| 153 | Swift, |
| 154 | |
| 155 | Swift5_0, |
| 156 | |
| 157 | Swift4_2, |
| 158 | |
| 159 | Swift4_1, |
| 160 | }; |
| 161 | |
| 162 | enum FPContractModeKind { |
| 163 | |
| 164 | FPC_Off, |
| 165 | |
| 166 | |
| 167 | FPC_On, |
| 168 | |
| 169 | |
| 170 | FPC_Fast |
| 171 | }; |
| 172 | |
| 173 | |
| 174 | enum FEnvAccessModeKind { |
| 175 | FEA_Off, |
| 176 | |
| 177 | FEA_On |
| 178 | }; |
| 179 | |
| 180 | |
| 181 | public: |
| 182 | |
| 183 | SanitizerSet Sanitize; |
| 184 | |
| 185 | |
| 186 | |
| 187 | std::vector<std::string> SanitizerBlacklistFiles; |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | |
| 193 | std::vector<std::string> XRayAlwaysInstrumentFiles; |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | std::vector<std::string> XRayNeverInstrumentFiles; |
| 200 | |
| 201 | |
| 202 | |
| 203 | |
| 204 | std::vector<std::string> XRayAttrListFiles; |
| 205 | |
| 206 | clang::ObjCRuntime ObjCRuntime; |
| 207 | |
| 208 | CoreFoundationABI CFRuntime = CoreFoundationABI::Unspecified; |
| 209 | |
| 210 | std::string ObjCConstantStringClass; |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | std::string OverflowHandler; |
| 217 | |
| 218 | |
| 219 | std::string ModuleName; |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | std::string CurrentModule; |
| 227 | |
| 228 | |
| 229 | |
| 230 | |
| 231 | |
| 232 | std::vector<std::string> ModuleFeatures; |
| 233 | |
| 234 | |
| 235 | CommentOptions ; |
| 236 | |
| 237 | |
| 238 | std::vector<std::string> NoBuiltinFuncs; |
| 239 | |
| 240 | |
| 241 | |
| 242 | std::vector<llvm::Triple> OMPTargetTriples; |
| 243 | |
| 244 | |
| 245 | |
| 246 | std::string OMPHostIRFile; |
| 247 | |
| 248 | |
| 249 | |
| 250 | bool = false; |
| 251 | |
| 252 | LangOptions(); |
| 253 | |
| 254 | |
| 255 | #define LANGOPT(Name, Bits, Default, Description) |
| 256 | #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ |
| 257 | Type get##Name() const { return static_cast<Type>(Name); } \ |
| 258 | void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } |
| 259 | #include "clang/Basic/LangOptions.def" |
| 260 | |
| 261 | |
| 262 | bool isCompilingModule() const { |
| 263 | return getCompilingModule() != CMK_None; |
| 264 | } |
| 265 | |
| 266 | |
| 267 | bool trackLocalOwningModule() const { |
| 268 | return isCompilingModule() || ModulesLocalVisibility || ModulesTS; |
| 269 | } |
| 270 | |
| 271 | bool isSignedOverflowDefined() const { |
| 272 | return getSignedOverflowBehavior() == SOB_Defined; |
| 273 | } |
| 274 | |
| 275 | bool isSubscriptPointerArithmetic() const { |
| 276 | return ObjCRuntime.isSubscriptPointerArithmetic() && |
| 277 | !ObjCSubscriptingLegacyRuntime; |
| 278 | } |
| 279 | |
| 280 | bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const { |
| 281 | return MSCompatibilityVersion >= MajorVersion * 100000U; |
| 282 | } |
| 283 | |
| 284 | |
| 285 | |
| 286 | void resetNonModularOptions(); |
| 287 | |
| 288 | |
| 289 | |
| 290 | bool isNoBuiltinFunc(StringRef Name) const; |
| 291 | |
| 292 | |
| 293 | bool allowsNonTrivialObjCLifetimeQualifiers() const { |
| 294 | return ObjCAutoRefCount || ObjCWeak; |
| 295 | } |
| 296 | |
| 297 | bool assumeFunctionsAreConvergent() const { |
| 298 | return (CUDA && CUDAIsDevice) || OpenCL; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | VersionTuple getOpenCLVersionTuple() const; |
| 303 | }; |
| 304 | |
| 305 | |
| 306 | class FPOptions { |
| 307 | public: |
| 308 | FPOptions() : fp_contract(LangOptions::FPC_Off), |
| 309 | fenv_access(LangOptions::FEA_Off) {} |
| 310 | |
| 311 | |
| 312 | explicit FPOptions(unsigned I) |
| 313 | : fp_contract(static_cast<LangOptions::FPContractModeKind>(I & 3)), |
| 314 | fenv_access(static_cast<LangOptions::FEnvAccessModeKind>((I >> 2) & 1)) |
| 315 | {} |
| 316 | |
| 317 | explicit FPOptions(const LangOptions &LangOpts) |
| 318 | : fp_contract(LangOpts.getDefaultFPContractMode()), |
| 319 | fenv_access(LangOptions::FEA_Off) {} |
| 320 | |
| 321 | |
| 322 | bool allowFPContractWithinStatement() const { |
| 323 | return fp_contract == LangOptions::FPC_On; |
| 324 | } |
| 325 | |
| 326 | bool allowFPContractAcrossStatement() const { |
| 327 | return fp_contract == LangOptions::FPC_Fast; |
| 328 | } |
| 329 | |
| 330 | void setAllowFPContractWithinStatement() { |
| 331 | fp_contract = LangOptions::FPC_On; |
| 332 | } |
| 333 | |
| 334 | void setAllowFPContractAcrossStatement() { |
| 335 | fp_contract = LangOptions::FPC_Fast; |
| 336 | } |
| 337 | |
| 338 | void setDisallowFPContract() { fp_contract = LangOptions::FPC_Off; } |
| 339 | |
| 340 | bool allowFEnvAccess() const { |
| 341 | return fenv_access == LangOptions::FEA_On; |
| 342 | } |
| 343 | |
| 344 | void setAllowFEnvAccess() { |
| 345 | fenv_access = LangOptions::FEA_On; |
| 346 | } |
| 347 | |
| 348 | void setDisallowFEnvAccess() { fenv_access = LangOptions::FEA_Off; } |
| 349 | |
| 350 | |
| 351 | unsigned getInt() const { return fp_contract | (fenv_access << 2); } |
| 352 | |
| 353 | private: |
| 354 | |
| 355 | |
| 356 | unsigned fp_contract : 2; |
| 357 | unsigned fenv_access : 1; |
| 358 | }; |
| 359 | |
| 360 | |
| 361 | enum TranslationUnitKind { |
| 362 | |
| 363 | TU_Complete, |
| 364 | |
| 365 | |
| 366 | |
| 367 | TU_Prefix, |
| 368 | |
| 369 | |
| 370 | TU_Module |
| 371 | }; |
| 372 | |
| 373 | } |
| 374 | |
| 375 | #endif |
| 376 | |