Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 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 | |
| 17 | namespace 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 Venet | ea684e6 | 2009-02-14 16:15:20 +0000 | [diff] [blame] | 21 | class LangOptions { |
| 22 | public: |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 23 | unsigned Trigraphs : 1; // Trigraphs in source files. |
Chris Lattner | d658b56 | 2008-04-05 06:32:51 +0000 | [diff] [blame] | 24 | unsigned BCPLComment : 1; // BCPL-style '//' comments. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 25 | unsigned DollarIdents : 1; // '$' allowed in identifiers. |
Daniel Dunbar | c157145 | 2008-12-01 18:55:22 +0000 | [diff] [blame] | 26 | unsigned AsmPreprocessor : 1; // Preprocessor in asm mode. |
Chris Lattner | 7e9c90b | 2009-03-20 15:44:26 +0000 | [diff] [blame] | 27 | unsigned GNUMode : 1; // True in gnu99 mode false in c99 mode (etc) |
Chris Lattner | d658b56 | 2008-04-05 06:32:51 +0000 | [diff] [blame] | 28 | unsigned ImplicitInt : 1; // C89 implicit 'int'. |
Chris Lattner | 3426b9b | 2008-02-25 04:01:39 +0000 | [diff] [blame] | 29 | unsigned Digraphs : 1; // C94, C99 and C++ |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 30 | 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 Lattner | d4b80f1 | 2007-07-16 04:18:29 +0000 | [diff] [blame] | 34 | unsigned CPlusPlus0x : 1; // C++0x Support |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 35 | unsigned CXXOperatorNames : 1; // Treat C++ operator names as keywords. |
| 36 | |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 37 | unsigned ObjC1 : 1; // Objective-C 1 support enabled. |
| 38 | unsigned ObjC2 : 1; // Objective-C 2 support enabled. |
Fariborz Jahanian | 34e6577 | 2009-05-22 20:17:16 +0000 | [diff] [blame^] | 39 | unsigned ObjCSenderDispatch: 1; // Objective-C 2 three-dimensional dispatch |
| 40 | // enabled. |
Fariborz Jahanian | 30bc571 | 2009-01-22 23:02:58 +0000 | [diff] [blame] | 41 | unsigned ObjCNonFragileABI : 1; // Objective-C modern abi enabled |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 42 | |
Anders Carlsson | ee98ac5 | 2007-10-15 02:50:23 +0000 | [diff] [blame] | 43 | unsigned PascalStrings : 1; // Allow Pascal strings |
Chris Lattner | 45e8cbd | 2007-11-28 05:34:05 +0000 | [diff] [blame] | 44 | unsigned WritableStrings : 1; // Allow writable strings |
Anders Carlsson | 695dbb6 | 2007-11-30 04:21:22 +0000 | [diff] [blame] | 45 | unsigned LaxVectorConversions : 1; |
Daniel Dunbar | 6379a7a | 2008-08-11 17:36:14 +0000 | [diff] [blame] | 46 | unsigned Exceptions : 1; // Support exception handling. |
Daniel Dunbar | f77ac86 | 2008-08-11 21:35:06 +0000 | [diff] [blame] | 47 | |
| 48 | unsigned NeXTRuntime : 1; // Use NeXT runtime. |
Douglas Gregor | 3573c0c | 2009-02-14 20:49:29 +0000 | [diff] [blame] | 49 | unsigned Freestanding : 1; // Freestanding implementation |
Chris Lattner | 7644f07 | 2009-03-13 22:38:49 +0000 | [diff] [blame] | 50 | unsigned NoBuiltin : 1; // Do not use builtin functions (-fno-builtin) |
Daniel Dunbar | f77ac86 | 2008-08-11 21:35:06 +0000 | [diff] [blame] | 51 | |
Anders Carlsson | e1b29ef | 2008-08-22 16:00:37 +0000 | [diff] [blame] | 52 | unsigned ThreadsafeStatics : 1; // Whether static initializers are protected |
Daniel Dunbar | c157145 | 2008-12-01 18:55:22 +0000 | [diff] [blame] | 53 | // by locks. |
Steve Naroff | 5618bd4 | 2008-08-27 16:04:49 +0000 | [diff] [blame] | 54 | unsigned Blocks : 1; // block extension to C |
Daniel Dunbar | d604c40 | 2009-02-04 21:19:06 +0000 | [diff] [blame] | 55 | unsigned EmitAllDecls : 1; // Emit all declarations, even if |
| 56 | // they are unused. |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 57 | unsigned MathErrno : 1; // Math functions must respect errno |
| 58 | // (modulo the platform support). |
| 59 | |
Mike Stump | 2add473 | 2009-04-01 20:28:16 +0000 | [diff] [blame] | 60 | unsigned OverflowChecking : 1; // Extension to call a handler function when |
Mike Stump | 5d8b2cf | 2009-04-02 01:03:55 +0000 | [diff] [blame] | 61 | // signed integer arithmetic overflows. |
Mike Stump | 2add473 | 2009-04-01 20:28:16 +0000 | [diff] [blame] | 62 | |
Chris Lattner | 810f6d5 | 2009-03-13 17:38:01 +0000 | [diff] [blame] | 63 | unsigned HeinousExtensions : 1; // Extensions that we really don't like and |
| 64 | // may be ripped out at any time. |
Fariborz Jahanian | 7cd2e93 | 2009-04-03 03:28:57 +0000 | [diff] [blame] | 65 | |
Anders Carlsson | 4ca076f | 2009-04-06 17:37:10 +0000 | [diff] [blame] | 66 | unsigned Optimize : 1; // Whether __OPTIMIZE__ should be defined. |
| 67 | unsigned OptimizeSize : 1; // Whether __OPTIMIZE_SIZE__ should be |
| 68 | // defined. |
Daniel Dunbar | 3bbc753 | 2009-04-08 18:03:55 +0000 | [diff] [blame] | 69 | unsigned Static : 1; // Should __STATIC__ be defined (as |
| 70 | // opposed to __DYNAMIC__). |
Daniel Dunbar | 9fd0b1f | 2009-04-08 03:03:23 +0000 | [diff] [blame] | 71 | unsigned PICLevel : 2; // The value for __PIC__, if non-zero. |
| 72 | |
Daniel Dunbar | 3bbc753 | 2009-04-08 18:03:55 +0000 | [diff] [blame] | 73 | unsigned GNUInline : 1; // Should GNU inline semantics be |
| 74 | // used (instead of C99 semantics). |
| 75 | unsigned NoInline : 1; // Should __NO_INLINE__ be defined. |
| 76 | |
Fariborz Jahanian | 448f5e6 | 2009-04-17 03:04:15 +0000 | [diff] [blame] | 77 | unsigned ObjCGCBitmapPrint : 1; // Enable printing of gc's bitmap layout |
| 78 | // for __weak/__strong ivars. |
| 79 | |
Anders Carlsson | a33d9b4 | 2009-05-13 19:49:53 +0000 | [diff] [blame] | 80 | unsigned AccessControl : 1; // Whether C++ access control should |
| 81 | // be enabled. |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 82 | private: |
| 83 | unsigned GC : 2; // Objective-C Garbage Collection modes. We declare |
| 84 | // this enum as unsigned because MSVC insists on making enums |
| 85 | // signed. Set/Query this value using accessors. |
Fariborz Jahanian | 7cd2e93 | 2009-04-03 03:28:57 +0000 | [diff] [blame] | 86 | unsigned SymbolVisibility : 3; // Symbol's visibility. |
| 87 | |
Daniel Dunbar | c9abc04 | 2009-04-08 05:11:16 +0000 | [diff] [blame] | 88 | /// The user provided name for the "main file", if non-null. This is |
| 89 | /// useful in situations where the input file name does not match |
| 90 | /// the original input file, for example with -save-temps. |
| 91 | const char *MainFileName; |
| 92 | |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 93 | public: |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 94 | unsigned InstantiationDepth; // Maximum template instantiation depth. |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 95 | |
| 96 | enum GCMode { NonGC, GCOnly, HybridGC }; |
Daniel Dunbar | 04d4078 | 2009-04-14 06:00:08 +0000 | [diff] [blame] | 97 | enum VisibilityMode { |
| 98 | Default, |
| 99 | Protected, |
| 100 | Hidden |
| 101 | }; |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 102 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 103 | LangOptions() { |
Daniel Dunbar | c157145 | 2008-12-01 18:55:22 +0000 | [diff] [blame] | 104 | Trigraphs = BCPLComment = DollarIdents = AsmPreprocessor = 0; |
Chris Lattner | 7e9c90b | 2009-03-20 15:44:26 +0000 | [diff] [blame] | 105 | GNUMode = ImplicitInt = Digraphs = 0; |
Chris Lattner | d658b56 | 2008-04-05 06:32:51 +0000 | [diff] [blame] | 106 | HexFloats = 0; |
Daniel Dunbar | 913af35 | 2009-05-07 21:58:26 +0000 | [diff] [blame] | 107 | GC = ObjC1 = ObjC2 = ObjCNonFragileABI = 0; |
Eli Friedman | c71133f | 2009-04-28 03:28:55 +0000 | [diff] [blame] | 108 | C99 = Microsoft = CPlusPlus = CPlusPlus0x = 0; |
| 109 | CXXOperatorNames = PascalStrings = WritableStrings = 0; |
Chris Lattner | 7644f07 | 2009-03-13 22:38:49 +0000 | [diff] [blame] | 110 | Exceptions = NeXTRuntime = Freestanding = NoBuiltin = 0; |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 111 | LaxVectorConversions = 1; |
Chris Lattner | 810f6d5 | 2009-03-13 17:38:01 +0000 | [diff] [blame] | 112 | HeinousExtensions = 0; |
Anders Carlsson | e1b29ef | 2008-08-22 16:00:37 +0000 | [diff] [blame] | 113 | |
Daniel Dunbar | 04d4078 | 2009-04-14 06:00:08 +0000 | [diff] [blame] | 114 | SymbolVisibility = (unsigned) Default; |
Chris Lattner | c83cb1b | 2009-04-03 15:52:00 +0000 | [diff] [blame] | 115 | |
Anders Carlsson | e1b29ef | 2008-08-22 16:00:37 +0000 | [diff] [blame] | 116 | // FIXME: The default should be 1. |
| 117 | ThreadsafeStatics = 0; |
Chris Lattner | ae0ee03 | 2008-12-04 23:20:07 +0000 | [diff] [blame] | 118 | Blocks = 0; |
Daniel Dunbar | d604c40 | 2009-02-04 21:19:06 +0000 | [diff] [blame] | 119 | EmitAllDecls = 0; |
Daniel Dunbar | ef2abfe | 2009-02-16 22:43:43 +0000 | [diff] [blame] | 120 | MathErrno = 1; |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 121 | |
Anders Carlsson | a33d9b4 | 2009-05-13 19:49:53 +0000 | [diff] [blame] | 122 | // FIXME: The default should be 1. |
| 123 | AccessControl = 0; |
| 124 | |
Mike Stump | 2add473 | 2009-04-01 20:28:16 +0000 | [diff] [blame] | 125 | OverflowChecking = 0; |
Fariborz Jahanian | 448f5e6 | 2009-04-17 03:04:15 +0000 | [diff] [blame] | 126 | ObjCGCBitmapPrint = 0; |
Mike Stump | 2add473 | 2009-04-01 20:28:16 +0000 | [diff] [blame] | 127 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 128 | InstantiationDepth = 99; |
Anders Carlsson | 4ca076f | 2009-04-06 17:37:10 +0000 | [diff] [blame] | 129 | |
| 130 | Optimize = 0; |
| 131 | OptimizeSize = 0; |
Daniel Dunbar | 9fd0b1f | 2009-04-08 03:03:23 +0000 | [diff] [blame] | 132 | |
Daniel Dunbar | 3bbc753 | 2009-04-08 18:03:55 +0000 | [diff] [blame] | 133 | Static = 0; |
Daniel Dunbar | 9fd0b1f | 2009-04-08 03:03:23 +0000 | [diff] [blame] | 134 | PICLevel = 0; |
Daniel Dunbar | c9abc04 | 2009-04-08 05:11:16 +0000 | [diff] [blame] | 135 | |
Daniel Dunbar | 3bbc753 | 2009-04-08 18:03:55 +0000 | [diff] [blame] | 136 | GNUInline = 0; |
| 137 | NoInline = 0; |
| 138 | |
Daniel Dunbar | c9abc04 | 2009-04-08 05:11:16 +0000 | [diff] [blame] | 139 | MainFileName = 0; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 140 | } |
Ted Kremenek | 4914209 | 2007-12-05 19:06:15 +0000 | [diff] [blame] | 141 | |
Ted Kremenek | 01d9dbf | 2008-04-29 04:37:03 +0000 | [diff] [blame] | 142 | GCMode getGCMode() const { return (GCMode) GC; } |
| 143 | void setGCMode(GCMode m) { GC = (unsigned) m; } |
Fariborz Jahanian | 7cd2e93 | 2009-04-03 03:28:57 +0000 | [diff] [blame] | 144 | |
Daniel Dunbar | c9abc04 | 2009-04-08 05:11:16 +0000 | [diff] [blame] | 145 | const char *getMainFileName() const { return MainFileName; } |
| 146 | void setMainFileName(const char *Name) { MainFileName = Name; } |
| 147 | |
Daniel Dunbar | 04d4078 | 2009-04-14 06:00:08 +0000 | [diff] [blame] | 148 | VisibilityMode getVisibilityMode() const { |
| 149 | return (VisibilityMode) SymbolVisibility; |
| 150 | } |
Fariborz Jahanian | 7cd2e93 | 2009-04-03 03:28:57 +0000 | [diff] [blame] | 151 | void setVisibilityMode(VisibilityMode v) { SymbolVisibility = (unsigned) v; } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 152 | }; |
| 153 | |
| 154 | } // end namespace clang |
| 155 | |
| 156 | #endif |