LangOptions.h revision 198092
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//===----------------------------------------------------------------------===// 9193326Sed// 10193326Sed// This file defines the LangOptions interface. 11193326Sed// 12193326Sed//===----------------------------------------------------------------------===// 13193326Sed 14193326Sed#ifndef LLVM_CLANG_LANGOPTIONS_H 15193326Sed#define LLVM_CLANG_LANGOPTIONS_H 16193326Sed 17193326Sednamespace clang { 18193326Sed 19193326Sed/// LangOptions - This class keeps track of the various options that can be 20193326Sed/// enabled, which controls the dialect of C that is accepted. 21193326Sedclass LangOptions { 22193326Sedpublic: 23193326Sed unsigned Trigraphs : 1; // Trigraphs in source files. 24193326Sed unsigned BCPLComment : 1; // BCPL-style '//' comments. 25195341Sed unsigned Bool : 1; // 'bool', 'true', 'false' keywords. 26193326Sed unsigned DollarIdents : 1; // '$' allowed in identifiers. 27193326Sed unsigned AsmPreprocessor : 1; // Preprocessor in asm mode. 28193326Sed unsigned GNUMode : 1; // True in gnu99 mode false in c99 mode (etc) 29193326Sed unsigned ImplicitInt : 1; // C89 implicit 'int'. 30193326Sed unsigned Digraphs : 1; // C94, C99 and C++ 31193326Sed unsigned HexFloats : 1; // C99 Hexadecimal float constants. 32193326Sed unsigned C99 : 1; // C99 Support 33193326Sed unsigned Microsoft : 1; // Microsoft extensions. 34193326Sed unsigned CPlusPlus : 1; // C++ Support 35193326Sed unsigned CPlusPlus0x : 1; // C++0x Support 36193326Sed unsigned CXXOperatorNames : 1; // Treat C++ operator names as keywords. 37198092Srdivacky 38193326Sed unsigned ObjC1 : 1; // Objective-C 1 support enabled. 39193326Sed unsigned ObjC2 : 1; // Objective-C 2 support enabled. 40193326Sed unsigned ObjCNonFragileABI : 1; // Objective-C modern abi enabled 41198092Srdivacky 42193326Sed unsigned PascalStrings : 1; // Allow Pascal strings 43193326Sed unsigned WritableStrings : 1; // Allow writable strings 44193326Sed unsigned LaxVectorConversions : 1; 45195099Sed unsigned AltiVec : 1; // Support AltiVec-style vector initializers. 46193326Sed unsigned Exceptions : 1; // Support exception handling. 47198092Srdivacky unsigned Rtti : 1; // Support rtti information. 48193326Sed 49193326Sed unsigned NeXTRuntime : 1; // Use NeXT runtime. 50193326Sed unsigned Freestanding : 1; // Freestanding implementation 51193326Sed unsigned NoBuiltin : 1; // Do not use builtin functions (-fno-builtin) 52193326Sed 53193326Sed unsigned ThreadsafeStatics : 1; // Whether static initializers are protected 54193326Sed // by locks. 55198092Srdivacky unsigned POSIXThreads : 1; // Compiling with POSIX thread support 56198092Srdivacky // (-pthread) 57193326Sed unsigned Blocks : 1; // block extension to C 58193326Sed unsigned EmitAllDecls : 1; // Emit all declarations, even if 59193326Sed // they are unused. 60193326Sed unsigned MathErrno : 1; // Math functions must respect errno 61193326Sed // (modulo the platform support). 62193326Sed 63193326Sed unsigned OverflowChecking : 1; // Extension to call a handler function when 64193326Sed // signed integer arithmetic overflows. 65193326Sed 66193326Sed unsigned HeinousExtensions : 1; // Extensions that we really don't like and 67193326Sed // may be ripped out at any time. 68193326Sed 69193326Sed unsigned Optimize : 1; // Whether __OPTIMIZE__ should be defined. 70198092Srdivacky unsigned OptimizeSize : 1; // Whether __OPTIMIZE_SIZE__ should be 71193326Sed // defined. 72193326Sed unsigned Static : 1; // Should __STATIC__ be defined (as 73193326Sed // opposed to __DYNAMIC__). 74193326Sed unsigned PICLevel : 2; // The value for __PIC__, if non-zero. 75193326Sed 76193326Sed unsigned GNUInline : 1; // Should GNU inline semantics be 77193326Sed // used (instead of C99 semantics). 78193326Sed unsigned NoInline : 1; // Should __NO_INLINE__ be defined. 79193326Sed 80193326Sed unsigned ObjCGCBitmapPrint : 1; // Enable printing of gc's bitmap layout 81193326Sed // for __weak/__strong ivars. 82193326Sed 83198092Srdivacky unsigned AccessControl : 1; // Whether C++ access control should 84193326Sed // be enabled. 85193576Sed unsigned CharIsSigned : 1; // Whether char is a signed or unsigned type 86195099Sed 87195099Sed unsigned OpenCL : 1; // OpenCL C99 language extensions. 88195099Sed 89198092Srdivacky unsigned ElideConstructors : 1; // Whether C++ copy constructors should be 90198092Srdivacky // elided if possible. 91193326Sedprivate: 92195341Sed unsigned GC : 2; // Objective-C Garbage Collection modes. We 93195341Sed // declare this enum as unsigned because MSVC 94195341Sed // insists on making enums signed. Set/Query 95195341Sed // this value using accessors. 96193326Sed unsigned SymbolVisibility : 3; // Symbol's visibility. 97195341Sed unsigned StackProtector : 2; // Whether stack protectors are on. We declare 98195341Sed // this enum as unsigned because MSVC insists 99195341Sed // on making enums signed. Set/Query this 100195341Sed // value using accessors. 101193326Sed 102193326Sed /// The user provided name for the "main file", if non-null. This is 103193326Sed /// useful in situations where the input file name does not match 104193326Sed /// the original input file, for example with -save-temps. 105193326Sed const char *MainFileName; 106193326Sed 107198092Srdivackypublic: 108193326Sed unsigned InstantiationDepth; // Maximum template instantiation depth. 109193326Sed 110198092Srdivacky const char *ObjCConstantStringClass; 111198092Srdivacky 112193326Sed enum GCMode { NonGC, GCOnly, HybridGC }; 113195341Sed enum StackProtectorMode { SSPOff, SSPOn, SSPReq }; 114198092Srdivacky enum VisibilityMode { 115198092Srdivacky Default, 116198092Srdivacky Protected, 117193326Sed Hidden 118193326Sed }; 119198092Srdivacky 120193326Sed LangOptions() { 121195341Sed Trigraphs = BCPLComment = Bool = DollarIdents = AsmPreprocessor = 0; 122193326Sed GNUMode = ImplicitInt = Digraphs = 0; 123193326Sed HexFloats = 0; 124193326Sed GC = ObjC1 = ObjC2 = ObjCNonFragileABI = 0; 125198092Srdivacky ObjCConstantStringClass = 0; 126193326Sed C99 = Microsoft = CPlusPlus = CPlusPlus0x = 0; 127193326Sed CXXOperatorNames = PascalStrings = WritableStrings = 0; 128193326Sed Exceptions = NeXTRuntime = Freestanding = NoBuiltin = 0; 129198092Srdivacky Rtti = 1; 130193326Sed LaxVectorConversions = 1; 131193326Sed HeinousExtensions = 0; 132195341Sed AltiVec = OpenCL = StackProtector = 0; 133198092Srdivacky 134193326Sed SymbolVisibility = (unsigned) Default; 135198092Srdivacky 136193326Sed // FIXME: The default should be 1. 137193326Sed ThreadsafeStatics = 0; 138198092Srdivacky POSIXThreads = 0; 139193326Sed Blocks = 0; 140193326Sed EmitAllDecls = 0; 141193326Sed MathErrno = 1; 142193326Sed 143193326Sed // FIXME: The default should be 1. 144193326Sed AccessControl = 0; 145198092Srdivacky ElideConstructors = 1; 146198092Srdivacky 147193326Sed OverflowChecking = 0; 148193326Sed ObjCGCBitmapPrint = 0; 149193326Sed 150193326Sed InstantiationDepth = 99; 151198092Srdivacky 152193326Sed Optimize = 0; 153193326Sed OptimizeSize = 0; 154193326Sed 155193326Sed Static = 0; 156193326Sed PICLevel = 0; 157193326Sed 158193326Sed GNUInline = 0; 159193326Sed NoInline = 0; 160193326Sed 161193576Sed CharIsSigned = 1; 162193576Sed 163193326Sed MainFileName = 0; 164193326Sed } 165198092Srdivacky 166193326Sed GCMode getGCMode() const { return (GCMode) GC; } 167193326Sed void setGCMode(GCMode m) { GC = (unsigned) m; } 168193326Sed 169195341Sed StackProtectorMode getStackProtectorMode() const { 170195341Sed return static_cast<StackProtectorMode>(StackProtector); 171195341Sed } 172195341Sed void setStackProtectorMode(StackProtectorMode m) { 173195341Sed StackProtector = static_cast<unsigned>(m); 174195341Sed } 175195341Sed 176193326Sed const char *getMainFileName() const { return MainFileName; } 177193326Sed void setMainFileName(const char *Name) { MainFileName = Name; } 178193326Sed 179198092Srdivacky VisibilityMode getVisibilityMode() const { 180198092Srdivacky return (VisibilityMode) SymbolVisibility; 181193326Sed } 182193326Sed void setVisibilityMode(VisibilityMode v) { SymbolVisibility = (unsigned) v; } 183193326Sed}; 184193326Sed 185193326Sed} // end namespace clang 186193326Sed 187193326Sed#endif 188