blob: 9b308e1b322cd003021bc88d15fa80c7f8a34ef4 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the LangOptions interface.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LANGOPTIONS_H
15#define LLVM_CLANG_LANGOPTIONS_H
16
17namespace clang {
18
19/// LangOptions - This class keeps track of the various options that can be
20/// enabled, which controls the dialect of C that is accepted.
Cedric Venetea684e62009-02-14 16:15:20 +000021class LangOptions {
22public:
Reid Spencer5f016e22007-07-11 17:01:13 +000023 unsigned Trigraphs : 1; // Trigraphs in source files.
Chris Lattnerd658b562008-04-05 06:32:51 +000024 unsigned BCPLComment : 1; // BCPL-style '//' comments.
Reid Spencer5f016e22007-07-11 17:01:13 +000025 unsigned DollarIdents : 1; // '$' allowed in identifiers.
Daniel Dunbarc1571452008-12-01 18:55:22 +000026 unsigned AsmPreprocessor : 1; // Preprocessor in asm mode.
Chris Lattner7e9c90b2009-03-20 15:44:26 +000027 unsigned GNUMode : 1; // True in gnu99 mode false in c99 mode (etc)
Chris Lattnerd658b562008-04-05 06:32:51 +000028 unsigned ImplicitInt : 1; // C89 implicit 'int'.
Chris Lattner3426b9b2008-02-25 04:01:39 +000029 unsigned Digraphs : 1; // C94, C99 and C++
Reid Spencer5f016e22007-07-11 17:01:13 +000030 unsigned HexFloats : 1; // C99 Hexadecimal float constants.
31 unsigned C99 : 1; // C99 Support
32 unsigned Microsoft : 1; // Microsoft extensions.
33 unsigned CPlusPlus : 1; // C++ Support
Chris Lattnerd4b80f12007-07-16 04:18:29 +000034 unsigned CPlusPlus0x : 1; // C++0x Support
Reid Spencer5f016e22007-07-11 17:01:13 +000035 unsigned CXXOperatorNames : 1; // Treat C++ operator names as keywords.
36
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000037 unsigned ObjC1 : 1; // Objective-C 1 support enabled.
38 unsigned ObjC2 : 1; // Objective-C 2 support enabled.
Fariborz Jahanian34e65772009-05-22 20:17:16 +000039 unsigned ObjCSenderDispatch: 1; // Objective-C 2 three-dimensional dispatch
40 // enabled.
Fariborz Jahanian30bc5712009-01-22 23:02:58 +000041 unsigned ObjCNonFragileABI : 1; // Objective-C modern abi enabled
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000042
Anders Carlssonee98ac52007-10-15 02:50:23 +000043 unsigned PascalStrings : 1; // Allow Pascal strings
Chris Lattner45e8cbd2007-11-28 05:34:05 +000044 unsigned WritableStrings : 1; // Allow writable strings
Anders Carlsson695dbb62007-11-30 04:21:22 +000045 unsigned LaxVectorConversions : 1;
Nate Begeman4e3629e2009-06-25 22:43:10 +000046 unsigned AltiVec : 1; // Support AltiVec-style vector initializers.
Daniel Dunbar6379a7a2008-08-11 17:36:14 +000047 unsigned Exceptions : 1; // Support exception handling.
Daniel Dunbarf77ac862008-08-11 21:35:06 +000048
49 unsigned NeXTRuntime : 1; // Use NeXT runtime.
Douglas Gregor3573c0c2009-02-14 20:49:29 +000050 unsigned Freestanding : 1; // Freestanding implementation
Chris Lattner7644f072009-03-13 22:38:49 +000051 unsigned NoBuiltin : 1; // Do not use builtin functions (-fno-builtin)
Daniel Dunbarf77ac862008-08-11 21:35:06 +000052
Anders Carlssone1b29ef2008-08-22 16:00:37 +000053 unsigned ThreadsafeStatics : 1; // Whether static initializers are protected
Daniel Dunbarc1571452008-12-01 18:55:22 +000054 // by locks.
Steve Naroff5618bd42008-08-27 16:04:49 +000055 unsigned Blocks : 1; // block extension to C
Daniel Dunbard604c402009-02-04 21:19:06 +000056 unsigned EmitAllDecls : 1; // Emit all declarations, even if
57 // they are unused.
Daniel Dunbaref2abfe2009-02-16 22:43:43 +000058 unsigned MathErrno : 1; // Math functions must respect errno
59 // (modulo the platform support).
60
Mike Stump2add4732009-04-01 20:28:16 +000061 unsigned OverflowChecking : 1; // Extension to call a handler function when
Mike Stump5d8b2cf2009-04-02 01:03:55 +000062 // signed integer arithmetic overflows.
Mike Stump2add4732009-04-01 20:28:16 +000063
Chris Lattner810f6d52009-03-13 17:38:01 +000064 unsigned HeinousExtensions : 1; // Extensions that we really don't like and
65 // may be ripped out at any time.
Fariborz Jahanian7cd2e932009-04-03 03:28:57 +000066
Anders Carlsson4ca076f2009-04-06 17:37:10 +000067 unsigned Optimize : 1; // Whether __OPTIMIZE__ should be defined.
68 unsigned OptimizeSize : 1; // Whether __OPTIMIZE_SIZE__ should be
69 // defined.
Daniel Dunbar3bbc7532009-04-08 18:03:55 +000070 unsigned Static : 1; // Should __STATIC__ be defined (as
71 // opposed to __DYNAMIC__).
Daniel Dunbar9fd0b1f2009-04-08 03:03:23 +000072 unsigned PICLevel : 2; // The value for __PIC__, if non-zero.
73
Daniel Dunbar3bbc7532009-04-08 18:03:55 +000074 unsigned GNUInline : 1; // Should GNU inline semantics be
75 // used (instead of C99 semantics).
76 unsigned NoInline : 1; // Should __NO_INLINE__ be defined.
77
Fariborz Jahanian448f5e62009-04-17 03:04:15 +000078 unsigned ObjCGCBitmapPrint : 1; // Enable printing of gc's bitmap layout
79 // for __weak/__strong ivars.
80
Anders Carlssona33d9b42009-05-13 19:49:53 +000081 unsigned AccessControl : 1; // Whether C++ access control should
82 // be enabled.
Eli Friedman15b91762009-06-05 07:05:05 +000083 unsigned CharIsSigned : 1; // Whether char is a signed or unsigned type
Nate Begeman4e3629e2009-06-25 22:43:10 +000084
85 unsigned OpenCL : 1; // OpenCL C99 language extensions.
86
Bill Wendling45483f72009-06-28 07:36:13 +000087 unsigned StackProtector : 2; // Whether stack protectors are on:
88 // 0 - None
89 // 1 - On
90 // 2 - All
Nate Begeman4e3629e2009-06-25 22:43:10 +000091
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000092private:
93 unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
94 // this enum as unsigned because MSVC insists on making enums
95 // signed. Set/Query this value using accessors.
Fariborz Jahanian7cd2e932009-04-03 03:28:57 +000096 unsigned SymbolVisibility : 3; // Symbol's visibility.
97
Daniel Dunbarc9abc042009-04-08 05:11:16 +000098 /// The user provided name for the "main file", if non-null. This is
99 /// useful in situations where the input file name does not match
100 /// the original input file, for example with -save-temps.
101 const char *MainFileName;
102
Ted Kremenek01d9dbf2008-04-29 04:37:03 +0000103public:
Douglas Gregor26dce442009-03-10 00:06:19 +0000104 unsigned InstantiationDepth; // Maximum template instantiation depth.
Ted Kremenek01d9dbf2008-04-29 04:37:03 +0000105
106 enum GCMode { NonGC, GCOnly, HybridGC };
Daniel Dunbar04d40782009-04-14 06:00:08 +0000107 enum VisibilityMode {
108 Default,
109 Protected,
110 Hidden
111 };
Ted Kremenek01d9dbf2008-04-29 04:37:03 +0000112
Reid Spencer5f016e22007-07-11 17:01:13 +0000113 LangOptions() {
Daniel Dunbarc1571452008-12-01 18:55:22 +0000114 Trigraphs = BCPLComment = DollarIdents = AsmPreprocessor = 0;
Chris Lattner7e9c90b2009-03-20 15:44:26 +0000115 GNUMode = ImplicitInt = Digraphs = 0;
Chris Lattnerd658b562008-04-05 06:32:51 +0000116 HexFloats = 0;
Daniel Dunbar913af352009-05-07 21:58:26 +0000117 GC = ObjC1 = ObjC2 = ObjCNonFragileABI = 0;
Eli Friedmanc71133f2009-04-28 03:28:55 +0000118 C99 = Microsoft = CPlusPlus = CPlusPlus0x = 0;
119 CXXOperatorNames = PascalStrings = WritableStrings = 0;
Chris Lattner7644f072009-03-13 22:38:49 +0000120 Exceptions = NeXTRuntime = Freestanding = NoBuiltin = 0;
Anders Carlssonb0f90cc2009-01-30 23:17:46 +0000121 LaxVectorConversions = 1;
Chris Lattner810f6d52009-03-13 17:38:01 +0000122 HeinousExtensions = 0;
Bill Wendling45483f72009-06-28 07:36:13 +0000123 AltiVec = OpenCL = StackProtector = 0;
Anders Carlssone1b29ef2008-08-22 16:00:37 +0000124
Daniel Dunbar04d40782009-04-14 06:00:08 +0000125 SymbolVisibility = (unsigned) Default;
Chris Lattnerc83cb1b2009-04-03 15:52:00 +0000126
Anders Carlssone1b29ef2008-08-22 16:00:37 +0000127 // FIXME: The default should be 1.
128 ThreadsafeStatics = 0;
Chris Lattnerae0ee032008-12-04 23:20:07 +0000129 Blocks = 0;
Daniel Dunbard604c402009-02-04 21:19:06 +0000130 EmitAllDecls = 0;
Daniel Dunbaref2abfe2009-02-16 22:43:43 +0000131 MathErrno = 1;
Douglas Gregor26dce442009-03-10 00:06:19 +0000132
Anders Carlssona33d9b42009-05-13 19:49:53 +0000133 // FIXME: The default should be 1.
134 AccessControl = 0;
135
Mike Stump2add4732009-04-01 20:28:16 +0000136 OverflowChecking = 0;
Fariborz Jahanian448f5e62009-04-17 03:04:15 +0000137 ObjCGCBitmapPrint = 0;
Fariborz Jahanian355bf952009-05-27 16:27:50 +0000138 ObjCSenderDispatch = 0;
Mike Stump2add4732009-04-01 20:28:16 +0000139
Douglas Gregor26dce442009-03-10 00:06:19 +0000140 InstantiationDepth = 99;
Anders Carlsson4ca076f2009-04-06 17:37:10 +0000141
142 Optimize = 0;
143 OptimizeSize = 0;
Daniel Dunbar9fd0b1f2009-04-08 03:03:23 +0000144
Daniel Dunbar3bbc7532009-04-08 18:03:55 +0000145 Static = 0;
Daniel Dunbar9fd0b1f2009-04-08 03:03:23 +0000146 PICLevel = 0;
Daniel Dunbarc9abc042009-04-08 05:11:16 +0000147
Daniel Dunbar3bbc7532009-04-08 18:03:55 +0000148 GNUInline = 0;
149 NoInline = 0;
150
Eli Friedman15b91762009-06-05 07:05:05 +0000151 CharIsSigned = 1;
152
Daniel Dunbarc9abc042009-04-08 05:11:16 +0000153 MainFileName = 0;
Reid Spencer5f016e22007-07-11 17:01:13 +0000154 }
Ted Kremenek49142092007-12-05 19:06:15 +0000155
Ted Kremenek01d9dbf2008-04-29 04:37:03 +0000156 GCMode getGCMode() const { return (GCMode) GC; }
157 void setGCMode(GCMode m) { GC = (unsigned) m; }
Fariborz Jahanian7cd2e932009-04-03 03:28:57 +0000158
Daniel Dunbarc9abc042009-04-08 05:11:16 +0000159 const char *getMainFileName() const { return MainFileName; }
160 void setMainFileName(const char *Name) { MainFileName = Name; }
161
Daniel Dunbar04d40782009-04-14 06:00:08 +0000162 VisibilityMode getVisibilityMode() const {
163 return (VisibilityMode) SymbolVisibility;
164 }
Fariborz Jahanian7cd2e932009-04-03 03:28:57 +0000165 void setVisibilityMode(VisibilityMode v) { SymbolVisibility = (unsigned) v; }
Reid Spencer5f016e22007-07-11 17:01:13 +0000166};
167
168} // end namespace clang
169
170#endif