1193326Sed//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===// 2193326Sed// 3193326Sed// The LLVM Compiler Infrastructure 4193326Sed// 5193326Sed// This file is distributed under the University of Illinois Open Source 6193326Sed// License. See LICENSE.TXT for details. 7193326Sed// 8193326Sed//===----------------------------------------------------------------------===// 9245431Sdim/// 10245431Sdim/// \file 11245431Sdim/// \brief Defines the clang::LangOptions interface. 12245431Sdim/// 13193326Sed//===----------------------------------------------------------------------===// 14193326Sed 15193326Sed#ifndef LLVM_CLANG_LANGOPTIONS_H 16193326Sed#define LLVM_CLANG_LANGOPTIONS_H 17193326Sed 18252723Sdim#include "clang/Basic/CommentOptions.h" 19235633Sdim#include "clang/Basic/LLVM.h" 20245431Sdim#include "clang/Basic/ObjCRuntime.h" 21218893Sdim#include "clang/Basic/Visibility.h" 22235633Sdim#include "llvm/ADT/IntrusiveRefCntPtr.h" 23252723Sdim#include <string> 24199990Srdivacky 25193326Sednamespace clang { 26193326Sed 27252723Sdimstruct SanitizerOptions { 28252723Sdim#define SANITIZER(NAME, ID) unsigned ID : 1; 29252723Sdim#include "clang/Basic/Sanitizers.def" 30252723Sdim 31252723Sdim /// \brief Cached set of sanitizer options with all sanitizers disabled. 32252723Sdim static const SanitizerOptions Disabled; 33252723Sdim}; 34252723Sdim 35235633Sdim/// Bitfields of LangOptions, split out from LangOptions in order to ensure that 36235633Sdim/// this large collection of bitfields is a trivial class type. 37235633Sdimclass LangOptionsBase { 38235633Sdimpublic: 39235633Sdim // Define simple language options (with no accessors). 40235633Sdim#define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits; 41235633Sdim#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) 42235633Sdim#include "clang/Basic/LangOptions.def" 43235633Sdim 44252723Sdim SanitizerOptions Sanitize; 45235633Sdimprotected: 46235633Sdim // Define language options of enumeration type. These are private, and will 47235633Sdim // have accessors (below). 48235633Sdim#define LANGOPT(Name, Bits, Default, Description) 49235633Sdim#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 50235633Sdim unsigned Name : Bits; 51235633Sdim#include "clang/Basic/LangOptions.def" 52235633Sdim}; 53235633Sdim 54245431Sdim/// \brief Keeps track of the various options that can be 55245431Sdim/// enabled, which controls the dialect of C or C++ that is accepted. 56235633Sdimclass LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase { 57193326Sedpublic: 58226890Sdim typedef clang::Visibility Visibility; 59226890Sdim 60193326Sed enum GCMode { NonGC, GCOnly, HybridGC }; 61195341Sed enum StackProtectorMode { SSPOff, SSPOn, SSPReq }; 62226890Sdim 63210299Sed enum SignedOverflowBehaviorTy { 64210299Sed SOB_Undefined, // Default C standard behavior. 65210299Sed SOB_Defined, // -fwrapv 66210299Sed SOB_Trapping // -ftrapv 67210299Sed }; 68226890Sdim 69263509Sdim enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off }; 70263509Sdim 71226890Sdimpublic: 72245431Sdim clang::ObjCRuntime ObjCRuntime; 73245431Sdim 74226890Sdim std::string ObjCConstantStringClass; 75226890Sdim 76245431Sdim /// \brief The name of the handler function to be called when -ftrapv is 77245431Sdim /// specified. 78245431Sdim /// 79218893Sdim /// If none is specified, abort (GCC-compatible behaviour). 80218893Sdim std::string OverflowHandler; 81198092Srdivacky 82235633Sdim /// \brief The name of the current module. 83235633Sdim std::string CurrentModule; 84252723Sdim 85252723Sdim /// \brief Options for parsing comments. 86252723Sdim CommentOptions CommentOpts; 87235633Sdim 88226890Sdim LangOptions(); 89198092Srdivacky 90226890Sdim // Define accessors/mutators for language options of enumeration type. 91226890Sdim#define LANGOPT(Name, Bits, Default, Description) 92226890Sdim#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 93226890Sdim Type get##Name() const { return static_cast<Type>(Name); } \ 94226890Sdim void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 95226890Sdim#include "clang/Basic/LangOptions.def" 96226890Sdim 97221345Sdim bool isSignedOverflowDefined() const { 98221345Sdim return getSignedOverflowBehavior() == SOB_Defined; 99218893Sdim } 100263509Sdim 101263509Sdim bool isSubscriptPointerArithmetic() const { 102263509Sdim return ObjCRuntime.isSubscriptPointerArithmetic() && 103263509Sdim !ObjCSubscriptingLegacyRuntime; 104263509Sdim } 105226890Sdim 106226890Sdim /// \brief Reset all of the options that are not considered when building a 107226890Sdim /// module. 108226890Sdim void resetNonModularOptions(); 109193326Sed}; 110193326Sed 111245431Sdim/// \brief Floating point control options 112218893Sdimclass FPOptions { 113218893Sdimpublic: 114218893Sdim unsigned fp_contract : 1; 115218893Sdim 116218893Sdim FPOptions() : fp_contract(0) {} 117218893Sdim 118218893Sdim FPOptions(const LangOptions &LangOpts) : 119218893Sdim fp_contract(LangOpts.DefaultFPContract) {} 120218893Sdim}; 121218893Sdim 122245431Sdim/// \brief OpenCL volatile options 123218893Sdimclass OpenCLOptions { 124218893Sdimpublic: 125218893Sdim#define OPENCLEXT(nm) unsigned nm : 1; 126218893Sdim#include "clang/Basic/OpenCLExtensions.def" 127218893Sdim 128218893Sdim OpenCLOptions() { 129218893Sdim#define OPENCLEXT(nm) nm = 0; 130218893Sdim#include "clang/Basic/OpenCLExtensions.def" 131218893Sdim } 132218893Sdim}; 133218893Sdim 134226890Sdim/// \brief Describes the kind of translation unit being processed. 135226890Sdimenum TranslationUnitKind { 136226890Sdim /// \brief The translation unit is a complete translation unit. 137226890Sdim TU_Complete, 138226890Sdim /// \brief The translation unit is a prefix to a translation unit, and is 139226890Sdim /// not complete. 140226890Sdim TU_Prefix, 141226890Sdim /// \brief The translation unit is a module. 142226890Sdim TU_Module 143226890Sdim}; 144226890Sdim 145193326Sed} // end namespace clang 146193326Sed 147193326Sed#endif 148