1 //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the LangOptions interface.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LANGOPTIONS_H
15 #define LLVM_CLANG_LANGOPTIONS_H
18 #include "clang/Basic/Visibility.h"
22 /// LangOptions - This class keeps track of the various options that can be
23 /// enabled, which controls the dialect of C that is accepted.
26 unsigned Trigraphs
: 1; // Trigraphs in source files.
27 unsigned BCPLComment
: 1; // BCPL-style '//' comments.
28 unsigned Bool
: 1; // 'bool', 'true', 'false' keywords.
29 unsigned DollarIdents
: 1; // '$' allowed in identifiers.
30 unsigned AsmPreprocessor
: 1; // Preprocessor in asm mode.
31 unsigned GNUMode
: 1; // True in gnu99 mode false in c99 mode (etc)
32 unsigned GNUKeywords
: 1; // True if GNU-only keywords are allowed
33 unsigned ImplicitInt
: 1; // C89 implicit 'int'.
34 unsigned Digraphs
: 1; // C94, C99 and C++
35 unsigned HexFloats
: 1; // C99 Hexadecimal float constants.
36 unsigned C99
: 1; // C99 Support
37 unsigned Microsoft
: 1; // Microsoft extensions.
38 unsigned Borland
: 1; // Borland extensions.
39 unsigned CPlusPlus
: 1; // C++ Support
40 unsigned CPlusPlus0x
: 1; // C++0x Support
41 unsigned CXXOperatorNames
: 1; // Treat C++ operator names as keywords.
43 unsigned ObjC1
: 1; // Objective-C 1 support enabled.
44 unsigned ObjC2
: 1; // Objective-C 2 support enabled.
45 unsigned ObjCNonFragileABI
: 1; // Objective-C modern abi enabled
46 unsigned ObjCNonFragileABI2
: 1; // Objective-C enhanced modern abi enabled
48 unsigned PascalStrings
: 1; // Allow Pascal strings
49 unsigned WritableStrings
: 1; // Allow writable strings
50 unsigned ConstStrings
: 1; // Add const qualifier to strings (-Wwrite-strings)
51 unsigned LaxVectorConversions
: 1;
52 unsigned AltiVec
: 1; // Support AltiVec-style vector initializers.
53 unsigned Exceptions
: 1; // Support exception handling.
54 unsigned SjLjExceptions
: 1; // Use setjmp-longjump exception handling.
55 unsigned RTTI
: 1; // Support RTTI information.
57 unsigned NeXTRuntime
: 1; // Use NeXT runtime.
58 unsigned Freestanding
: 1; // Freestanding implementation
59 unsigned NoBuiltin
: 1; // Do not use builtin functions (-fno-builtin)
61 unsigned ThreadsafeStatics
: 1; // Whether static initializers are protected
63 unsigned POSIXThreads
: 1; // Compiling with POSIX thread support
65 unsigned Blocks
: 1; // block extension to C
66 unsigned EmitAllDecls
: 1; // Emit all declarations, even if
68 unsigned MathErrno
: 1; // Math functions must respect errno
69 // (modulo the platform support).
71 unsigned HeinousExtensions
: 1; // Extensions that we really don't like and
72 // may be ripped out at any time.
74 unsigned Optimize
: 1; // Whether __OPTIMIZE__ should be defined.
75 unsigned OptimizeSize
: 1; // Whether __OPTIMIZE_SIZE__ should be
77 unsigned Static
: 1; // Should __STATIC__ be defined (as
78 // opposed to __DYNAMIC__).
79 unsigned PICLevel
: 2; // The value for __PIC__, if non-zero.
81 unsigned GNUInline
: 1; // Should GNU inline semantics be
82 // used (instead of C99 semantics).
83 unsigned NoInline
: 1; // Should __NO_INLINE__ be defined.
85 unsigned ObjCGCBitmapPrint
: 1; // Enable printing of gc's bitmap layout
86 // for __weak/__strong ivars.
88 unsigned AccessControl
: 1; // Whether C++ access control should
90 unsigned CharIsSigned
: 1; // Whether char is a signed or unsigned type
91 unsigned ShortWChar
: 1; // Force wchar_t to be unsigned short int.
93 unsigned ShortEnums
: 1; // The enum type will be equivalent to the
94 // smallest integer type with enough room.
96 unsigned OpenCL
: 1; // OpenCL C99 language extensions.
98 unsigned AssumeSaneOperatorNew
: 1; // Whether to add __attribute__((malloc))
99 // to the declaration of C++'s new
101 unsigned ElideConstructors
: 1; // Whether C++ copy constructors should be
102 // elided if possible.
103 unsigned CatchUndefined
: 1; // Generate code to check for undefined ops.
104 unsigned DumpRecordLayouts
: 1; /// Dump the layout of IRgen'd records.
105 unsigned DumpVTableLayouts
: 1; /// Dump the layouts of emitted vtables.
106 unsigned NoConstantCFStrings
: 1; // Do not do CF strings
107 unsigned InlineVisibilityHidden
: 1; // Whether inline C++ methods have
108 // hidden visibility by default.
110 unsigned SpellChecking
: 1; // Whether to perform spell-checking for error
112 // FIXME: This is just a temporary option, for testing purposes.
113 unsigned NoBitFieldTypeAlign
: 1;
116 // We declare multibit enums as unsigned because MSVC insists on making enums
117 // signed. Set/Query these values using accessors.
118 unsigned GC
: 2; // Objective-C Garbage Collection modes.
119 unsigned SymbolVisibility
: 3; // Symbol's visibility.
120 unsigned StackProtector
: 2; // Whether stack protectors are on.
121 unsigned SignedOverflowBehavior
: 2; // How to handle signed integer overflow.
124 unsigned InstantiationDepth
; // Maximum template instantiation depth.
125 unsigned NumLargeByValueCopy
; // Warn if parameter/return value is larger
126 // in bytes than this setting. 0 is no check.
128 // Version of Microsoft Visual C/C++ we are pretending to be. This is
129 // temporary until we support all MS extensions used in Windows SDK and stdlib
130 // headers. Sets _MSC_VER.
133 std::string ObjCConstantStringClass
;
135 enum GCMode
{ NonGC
, GCOnly
, HybridGC
};
136 enum StackProtectorMode
{ SSPOff
, SSPOn
, SSPReq
};
138 enum SignedOverflowBehaviorTy
{
139 SOB_Undefined
, // Default C standard behavior.
140 SOB_Defined
, // -fwrapv
141 SOB_Trapping
// -ftrapv
143 /// The name of the handler function to be called when -ftrapv is specified.
144 /// If none is specified, abort (GCC-compatible behaviour).
145 std::string OverflowHandler
;
148 Trigraphs
= BCPLComment
= Bool
= DollarIdents
= AsmPreprocessor
= 0;
149 GNUMode
= GNUKeywords
= ImplicitInt
= Digraphs
= 0;
151 GC
= ObjC1
= ObjC2
= ObjCNonFragileABI
= ObjCNonFragileABI2
= 0;
152 NoConstantCFStrings
= 0; InlineVisibilityHidden
= 0;
153 C99
= Microsoft
= Borland
= CPlusPlus
= CPlusPlus0x
= 0;
154 CXXOperatorNames
= PascalStrings
= WritableStrings
= ConstStrings
= 0;
155 Exceptions
= SjLjExceptions
= Freestanding
= NoBuiltin
= 0;
158 LaxVectorConversions
= 1;
159 HeinousExtensions
= 0;
160 AltiVec
= OpenCL
= StackProtector
= 0;
162 SymbolVisibility
= (unsigned) DefaultVisibility
;
164 ThreadsafeStatics
= 1;
169 SignedOverflowBehavior
= SOB_Undefined
;
171 AssumeSaneOperatorNew
= 1;
173 ElideConstructors
= 1;
175 SignedOverflowBehavior
= 0;
176 ObjCGCBitmapPrint
= 0;
178 InstantiationDepth
= 1024;
180 NumLargeByValueCopy
= 0;
195 DumpRecordLayouts
= 0;
196 DumpVTableLayouts
= 0;
198 NoBitFieldTypeAlign
= 0;
201 GCMode
getGCMode() const { return (GCMode
) GC
; }
202 void setGCMode(GCMode m
) { GC
= (unsigned) m
; }
204 StackProtectorMode
getStackProtectorMode() const {
205 return static_cast<StackProtectorMode
>(StackProtector
);
207 void setStackProtectorMode(StackProtectorMode m
) {
208 StackProtector
= static_cast<unsigned>(m
);
211 Visibility
getVisibilityMode() const {
212 return (Visibility
) SymbolVisibility
;
214 void setVisibilityMode(Visibility v
) { SymbolVisibility
= (unsigned) v
; }
216 SignedOverflowBehaviorTy
getSignedOverflowBehavior() const {
217 return (SignedOverflowBehaviorTy
)SignedOverflowBehavior
;
219 void setSignedOverflowBehavior(SignedOverflowBehaviorTy V
) {
220 SignedOverflowBehavior
= (unsigned)V
;
224 } // end namespace clang