1f4a2713aSLionel Sambuc //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===// 2f4a2713aSLionel Sambuc // 3f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure 4f4a2713aSLionel Sambuc // 5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source 6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details. 7f4a2713aSLionel Sambuc // 8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===// 9f4a2713aSLionel Sambuc /// 10f4a2713aSLionel Sambuc /// \file 11f4a2713aSLionel Sambuc /// \brief Defines the clang::LangOptions interface. 12f4a2713aSLionel Sambuc /// 13f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===// 14f4a2713aSLionel Sambuc 15*0a6a1f1dSLionel Sambuc #ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H 16*0a6a1f1dSLionel Sambuc #define LLVM_CLANG_BASIC_LANGOPTIONS_H 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc #include "clang/Basic/CommentOptions.h" 19f4a2713aSLionel Sambuc #include "clang/Basic/LLVM.h" 20f4a2713aSLionel Sambuc #include "clang/Basic/ObjCRuntime.h" 21*0a6a1f1dSLionel Sambuc #include "clang/Basic/Sanitizers.h" 22f4a2713aSLionel Sambuc #include "clang/Basic/Visibility.h" 23f4a2713aSLionel Sambuc #include <string> 24f4a2713aSLionel Sambuc 25f4a2713aSLionel Sambuc namespace clang { 26f4a2713aSLionel Sambuc 27f4a2713aSLionel Sambuc /// Bitfields of LangOptions, split out from LangOptions in order to ensure that 28f4a2713aSLionel Sambuc /// this large collection of bitfields is a trivial class type. 29f4a2713aSLionel Sambuc class LangOptionsBase { 30f4a2713aSLionel Sambuc public: 31f4a2713aSLionel Sambuc // Define simple language options (with no accessors). 32f4a2713aSLionel Sambuc #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits; 33f4a2713aSLionel Sambuc #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) 34f4a2713aSLionel Sambuc #include "clang/Basic/LangOptions.def" 35f4a2713aSLionel Sambuc 36f4a2713aSLionel Sambuc protected: 37f4a2713aSLionel Sambuc // Define language options of enumeration type. These are private, and will 38f4a2713aSLionel Sambuc // have accessors (below). 39f4a2713aSLionel Sambuc #define LANGOPT(Name, Bits, Default, Description) 40f4a2713aSLionel Sambuc #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 41f4a2713aSLionel Sambuc unsigned Name : Bits; 42f4a2713aSLionel Sambuc #include "clang/Basic/LangOptions.def" 43f4a2713aSLionel Sambuc }; 44f4a2713aSLionel Sambuc 45f4a2713aSLionel Sambuc /// \brief Keeps track of the various options that can be 46f4a2713aSLionel Sambuc /// enabled, which controls the dialect of C or C++ that is accepted. 47*0a6a1f1dSLionel Sambuc class LangOptions : public LangOptionsBase { 48f4a2713aSLionel Sambuc public: 49f4a2713aSLionel Sambuc typedef clang::Visibility Visibility; 50f4a2713aSLionel Sambuc 51f4a2713aSLionel Sambuc enum GCMode { NonGC, GCOnly, HybridGC }; 52*0a6a1f1dSLionel Sambuc enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq }; 53f4a2713aSLionel Sambuc 54f4a2713aSLionel Sambuc enum SignedOverflowBehaviorTy { 55f4a2713aSLionel Sambuc SOB_Undefined, // Default C standard behavior. 56f4a2713aSLionel Sambuc SOB_Defined, // -fwrapv 57f4a2713aSLionel Sambuc SOB_Trapping // -ftrapv 58f4a2713aSLionel Sambuc }; 59f4a2713aSLionel Sambuc 60*0a6a1f1dSLionel Sambuc enum PragmaMSPointersToMembersKind { 61*0a6a1f1dSLionel Sambuc PPTMK_BestCase, 62*0a6a1f1dSLionel Sambuc PPTMK_FullGeneralitySingleInheritance, 63*0a6a1f1dSLionel Sambuc PPTMK_FullGeneralityMultipleInheritance, 64*0a6a1f1dSLionel Sambuc PPTMK_FullGeneralityVirtualInheritance 65*0a6a1f1dSLionel Sambuc }; 66*0a6a1f1dSLionel Sambuc 67f4a2713aSLionel Sambuc enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off }; 68f4a2713aSLionel Sambuc 69f4a2713aSLionel Sambuc public: 70*0a6a1f1dSLionel Sambuc /// \brief Set of enabled sanitizers. 71*0a6a1f1dSLionel Sambuc SanitizerSet Sanitize; 72*0a6a1f1dSLionel Sambuc 73*0a6a1f1dSLionel Sambuc /// \brief Path to blacklist file specifying which objects 74*0a6a1f1dSLionel Sambuc /// (files, functions, variables) should not be instrumented. 75*0a6a1f1dSLionel Sambuc std::string SanitizerBlacklistFile; 76*0a6a1f1dSLionel Sambuc 77f4a2713aSLionel Sambuc clang::ObjCRuntime ObjCRuntime; 78f4a2713aSLionel Sambuc 79f4a2713aSLionel Sambuc std::string ObjCConstantStringClass; 80f4a2713aSLionel Sambuc 81f4a2713aSLionel Sambuc /// \brief The name of the handler function to be called when -ftrapv is 82f4a2713aSLionel Sambuc /// specified. 83f4a2713aSLionel Sambuc /// 84f4a2713aSLionel Sambuc /// If none is specified, abort (GCC-compatible behaviour). 85f4a2713aSLionel Sambuc std::string OverflowHandler; 86f4a2713aSLionel Sambuc 87f4a2713aSLionel Sambuc /// \brief The name of the current module. 88f4a2713aSLionel Sambuc std::string CurrentModule; 89f4a2713aSLionel Sambuc 90*0a6a1f1dSLionel Sambuc /// \brief The name of the module that the translation unit is an 91*0a6a1f1dSLionel Sambuc /// implementation of. Prevents semantic imports, but does not otherwise 92*0a6a1f1dSLionel Sambuc /// treat this as the CurrentModule. 93*0a6a1f1dSLionel Sambuc std::string ImplementationOfModule; 94*0a6a1f1dSLionel Sambuc 95f4a2713aSLionel Sambuc /// \brief Options for parsing comments. 96f4a2713aSLionel Sambuc CommentOptions CommentOpts; 97f4a2713aSLionel Sambuc 98f4a2713aSLionel Sambuc LangOptions(); 99f4a2713aSLionel Sambuc 100f4a2713aSLionel Sambuc // Define accessors/mutators for language options of enumeration type. 101f4a2713aSLionel Sambuc #define LANGOPT(Name, Bits, Default, Description) 102f4a2713aSLionel Sambuc #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 103f4a2713aSLionel Sambuc Type get##Name() const { return static_cast<Type>(Name); } \ 104f4a2713aSLionel Sambuc void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 105f4a2713aSLionel Sambuc #include "clang/Basic/LangOptions.def" 106f4a2713aSLionel Sambuc isSignedOverflowDefined()107f4a2713aSLionel Sambuc bool isSignedOverflowDefined() const { 108f4a2713aSLionel Sambuc return getSignedOverflowBehavior() == SOB_Defined; 109f4a2713aSLionel Sambuc } 110f4a2713aSLionel Sambuc isSubscriptPointerArithmetic()111f4a2713aSLionel Sambuc bool isSubscriptPointerArithmetic() const { 112f4a2713aSLionel Sambuc return ObjCRuntime.isSubscriptPointerArithmetic() && 113f4a2713aSLionel Sambuc !ObjCSubscriptingLegacyRuntime; 114f4a2713aSLionel Sambuc } 115f4a2713aSLionel Sambuc 116f4a2713aSLionel Sambuc /// \brief Reset all of the options that are not considered when building a 117f4a2713aSLionel Sambuc /// module. 118f4a2713aSLionel Sambuc void resetNonModularOptions(); 119f4a2713aSLionel Sambuc }; 120f4a2713aSLionel Sambuc 121f4a2713aSLionel Sambuc /// \brief Floating point control options 122f4a2713aSLionel Sambuc class FPOptions { 123f4a2713aSLionel Sambuc public: 124f4a2713aSLionel Sambuc unsigned fp_contract : 1; 125f4a2713aSLionel Sambuc FPOptions()126f4a2713aSLionel Sambuc FPOptions() : fp_contract(0) {} 127f4a2713aSLionel Sambuc FPOptions(const LangOptions & LangOpts)128f4a2713aSLionel Sambuc FPOptions(const LangOptions &LangOpts) : 129f4a2713aSLionel Sambuc fp_contract(LangOpts.DefaultFPContract) {} 130f4a2713aSLionel Sambuc }; 131f4a2713aSLionel Sambuc 132f4a2713aSLionel Sambuc /// \brief OpenCL volatile options 133f4a2713aSLionel Sambuc class OpenCLOptions { 134f4a2713aSLionel Sambuc public: 135f4a2713aSLionel Sambuc #define OPENCLEXT(nm) unsigned nm : 1; 136f4a2713aSLionel Sambuc #include "clang/Basic/OpenCLExtensions.def" 137f4a2713aSLionel Sambuc OpenCLOptions()138f4a2713aSLionel Sambuc OpenCLOptions() { 139f4a2713aSLionel Sambuc #define OPENCLEXT(nm) nm = 0; 140f4a2713aSLionel Sambuc #include "clang/Basic/OpenCLExtensions.def" 141f4a2713aSLionel Sambuc } 142f4a2713aSLionel Sambuc }; 143f4a2713aSLionel Sambuc 144f4a2713aSLionel Sambuc /// \brief Describes the kind of translation unit being processed. 145f4a2713aSLionel Sambuc enum TranslationUnitKind { 146f4a2713aSLionel Sambuc /// \brief The translation unit is a complete translation unit. 147f4a2713aSLionel Sambuc TU_Complete, 148f4a2713aSLionel Sambuc /// \brief The translation unit is a prefix to a translation unit, and is 149f4a2713aSLionel Sambuc /// not complete. 150f4a2713aSLionel Sambuc TU_Prefix, 151f4a2713aSLionel Sambuc /// \brief The translation unit is a module. 152f4a2713aSLionel Sambuc TU_Module 153f4a2713aSLionel Sambuc }; 154f4a2713aSLionel Sambuc 155f4a2713aSLionel Sambuc } // end namespace clang 156f4a2713aSLionel Sambuc 157f4a2713aSLionel Sambuc #endif 158