blob: 4b5355282ea79b7c3c41a37957ef95edfc6d5061 [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
Ted Kremenek49142092007-12-05 19:06:15 +000017#include "llvm/Bitcode/SerializationFwd.h"
18
Reid Spencer5f016e22007-07-11 17:01:13 +000019namespace clang {
20
21/// LangOptions - This class keeps track of the various options that can be
22/// enabled, which controls the dialect of C that is accepted.
23struct LangOptions {
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000024
Reid Spencer5f016e22007-07-11 17:01:13 +000025 unsigned Trigraphs : 1; // Trigraphs in source files.
Chris Lattnerd658b562008-04-05 06:32:51 +000026 unsigned BCPLComment : 1; // BCPL-style '//' comments.
Reid Spencer5f016e22007-07-11 17:01:13 +000027 unsigned DollarIdents : 1; // '$' allowed in identifiers.
Daniel Dunbarc1571452008-12-01 18:55:22 +000028 unsigned AsmPreprocessor : 1; // Preprocessor in asm mode.
Chris Lattnerd658b562008-04-05 06:32:51 +000029 unsigned ImplicitInt : 1; // C89 implicit 'int'.
Chris Lattner3426b9b2008-02-25 04:01:39 +000030 unsigned Digraphs : 1; // C94, C99 and C++
Reid Spencer5f016e22007-07-11 17:01:13 +000031 unsigned HexFloats : 1; // C99 Hexadecimal float constants.
32 unsigned C99 : 1; // C99 Support
33 unsigned Microsoft : 1; // Microsoft extensions.
34 unsigned CPlusPlus : 1; // C++ Support
Chris Lattnerd4b80f12007-07-16 04:18:29 +000035 unsigned CPlusPlus0x : 1; // C++0x Support
Reid Spencer5f016e22007-07-11 17:01:13 +000036 unsigned NoExtensions : 1; // All extensions are disabled, strict mode.
37 unsigned CXXOperatorNames : 1; // Treat C++ operator names as keywords.
38
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000039 unsigned ObjC1 : 1; // Objective-C 1 support enabled.
40 unsigned ObjC2 : 1; // Objective-C 2 support enabled.
41
Anders Carlssonee98ac52007-10-15 02:50:23 +000042 unsigned PascalStrings : 1; // Allow Pascal strings
Nate Begeman8aebcb72007-11-15 07:30:50 +000043 unsigned Boolean : 1; // Allow bool/true/false
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;
Daniel Dunbar6379a7a2008-08-11 17:36:14 +000046 unsigned Exceptions : 1; // Support exception handling.
Daniel Dunbarf77ac862008-08-11 21:35:06 +000047
48 unsigned NeXTRuntime : 1; // Use NeXT runtime.
49
Anders Carlssone1b29ef2008-08-22 16:00:37 +000050 unsigned ThreadsafeStatics : 1; // Whether static initializers are protected
Daniel Dunbarc1571452008-12-01 18:55:22 +000051 // by locks.
Steve Naroff5618bd42008-08-27 16:04:49 +000052 unsigned Blocks : 1; // block extension to C
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000053private:
54 unsigned GC : 2; // Objective-C Garbage Collection modes. We declare
55 // this enum as unsigned because MSVC insists on making enums
56 // signed. Set/Query this value using accessors.
57public:
58
59 enum GCMode { NonGC, GCOnly, HybridGC };
60
Reid Spencer5f016e22007-07-11 17:01:13 +000061 LangOptions() {
Daniel Dunbarc1571452008-12-01 18:55:22 +000062 Trigraphs = BCPLComment = DollarIdents = AsmPreprocessor = 0;
63 ImplicitInt = Digraphs = 0;
Chris Lattnerd658b562008-04-05 06:32:51 +000064 HexFloats = 0;
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000065 GC = ObjC1 = ObjC2 = 0;
Chris Lattnerd4b80f12007-07-16 04:18:29 +000066 C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;
Chris Lattner45e8cbd2007-11-28 05:34:05 +000067 CXXOperatorNames = PascalStrings = Boolean = WritableStrings = 0;
Anders Carlssone1b29ef2008-08-22 16:00:37 +000068 LaxVectorConversions = Exceptions = NeXTRuntime = 0;
69
70 // FIXME: The default should be 1.
71 ThreadsafeStatics = 0;
Chris Lattnerae0ee032008-12-04 23:20:07 +000072 Blocks = 0;
Reid Spencer5f016e22007-07-11 17:01:13 +000073 }
Ted Kremenek49142092007-12-05 19:06:15 +000074
Ted Kremenek01d9dbf2008-04-29 04:37:03 +000075 GCMode getGCMode() const { return (GCMode) GC; }
76 void setGCMode(GCMode m) { GC = (unsigned) m; }
77
Ted Kremenek49142092007-12-05 19:06:15 +000078 /// Emit - Emit this LangOptions object to bitcode.
79 void Emit(llvm::Serializer& S) const;
80
81 /// Read - Read new values for this LangOption object from bitcode.
82 void Read(llvm::Deserializer& S);
Reid Spencer5f016e22007-07-11 17:01:13 +000083};
84
85} // end namespace clang
86
87#endif