aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/LangOptions.h
blob: 4b5355282ea79b7c3c41a37957ef95edfc6d5061 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
//  This file defines the LangOptions interface.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_LANGOPTIONS_H
#define LLVM_CLANG_LANGOPTIONS_H

#include "llvm/Bitcode/SerializationFwd.h"

namespace clang {

/// LangOptions - This class keeps track of the various options that can be
/// enabled, which controls the dialect of C that is accepted.
struct LangOptions {
  
  unsigned Trigraphs         : 1;  // Trigraphs in source files.
  unsigned BCPLComment       : 1;  // BCPL-style '//' comments.
  unsigned DollarIdents      : 1;  // '$' allowed in identifiers.
  unsigned AsmPreprocessor   : 1;  // Preprocessor in asm mode.
  unsigned ImplicitInt       : 1;  // C89 implicit 'int'.
  unsigned Digraphs          : 1;  // C94, C99 and C++
  unsigned HexFloats         : 1;  // C99 Hexadecimal float constants.
  unsigned C99               : 1;  // C99 Support
  unsigned Microsoft         : 1;  // Microsoft extensions.
  unsigned CPlusPlus         : 1;  // C++ Support
  unsigned CPlusPlus0x       : 1;  // C++0x Support
  unsigned NoExtensions      : 1;  // All extensions are disabled, strict mode.
  unsigned CXXOperatorNames  : 1;  // Treat C++ operator names as keywords.
    
  unsigned ObjC1             : 1;  // Objective-C 1 support enabled.
  unsigned ObjC2             : 1;  // Objective-C 2 support enabled.
    
  unsigned PascalStrings     : 1;  // Allow Pascal strings
  unsigned Boolean           : 1;  // Allow bool/true/false
  unsigned WritableStrings   : 1;  // Allow writable strings
  unsigned LaxVectorConversions : 1;
  unsigned Exceptions        : 1;  // Support exception handling.

  unsigned NeXTRuntime       : 1; // Use NeXT runtime.

  unsigned ThreadsafeStatics : 1; // Whether static initializers are protected
                                  // by locks.
  unsigned Blocks            : 1; // block extension to C
private:
  unsigned GC : 2; // Objective-C Garbage Collection modes.  We declare
                   // this enum as unsigned because MSVC insists on making enums
                   // signed.  Set/Query this value using accessors.  
public:  

  enum GCMode { NonGC, GCOnly, HybridGC };
  
  LangOptions() {
    Trigraphs = BCPLComment = DollarIdents = AsmPreprocessor = 0;
    ImplicitInt = Digraphs = 0;
    HexFloats = 0;
    GC = ObjC1 = ObjC2 = 0;
    C99 = Microsoft = CPlusPlus = CPlusPlus0x = NoExtensions = 0;
    CXXOperatorNames = PascalStrings = Boolean = WritableStrings = 0;
    LaxVectorConversions = Exceptions = NeXTRuntime = 0;
    
    // FIXME: The default should be 1.
    ThreadsafeStatics = 0;
    Blocks = 0;
  }
  
  GCMode getGCMode() const { return (GCMode) GC; }
  void setGCMode(GCMode m) { GC = (unsigned) m; }
  
  /// Emit - Emit this LangOptions object to bitcode.
  void Emit(llvm::Serializer& S) const;
  
  /// Read - Read new values for this LangOption object from bitcode.
  void Read(llvm::Deserializer& S);  
};

}  // end namespace clang

#endif