1//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
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#include <string>
18#include "clang/Basic/LLVM.h"
19#include "clang/Basic/Visibility.h"
20#include "llvm/ADT/IntrusiveRefCntPtr.h"
21
22namespace clang {
23
24/// Bitfields of LangOptions, split out from LangOptions in order to ensure that
25/// this large collection of bitfields is a trivial class type.
26class LangOptionsBase {
27public:
28  // Define simple language options (with no accessors).
29#define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
30#define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
31#include "clang/Basic/LangOptions.def"
32
33protected:
34  // Define language options of enumeration type. These are private, and will
35  // have accessors (below).
36#define LANGOPT(Name, Bits, Default, Description)
37#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
38  unsigned Name : Bits;
39#include "clang/Basic/LangOptions.def"
40};
41
42/// LangOptions - This class keeps track of the various options that can be
43/// enabled, which controls the dialect of C that is accepted.
44class LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase {
45public:
46  typedef clang::Visibility Visibility;
47
48  enum GCMode { NonGC, GCOnly, HybridGC };
49  enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
50
51  enum SignedOverflowBehaviorTy {
52    SOB_Undefined,  // Default C standard behavior.
53    SOB_Defined,    // -fwrapv
54    SOB_Trapping    // -ftrapv
55  };
56
57public:
58  std::string ObjCConstantStringClass;
59
60  /// The name of the handler function to be called when -ftrapv is specified.
61  /// If none is specified, abort (GCC-compatible behaviour).
62  std::string OverflowHandler;
63
64  /// \brief The name of the current module.
65  std::string CurrentModule;
66
67  LangOptions();
68
69  // Define accessors/mutators for language options of enumeration type.
70#define LANGOPT(Name, Bits, Default, Description)
71#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
72  Type get##Name() const { return static_cast<Type>(Name); } \
73  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
74#include "clang/Basic/LangOptions.def"
75
76  bool isSignedOverflowDefined() const {
77    return getSignedOverflowBehavior() == SOB_Defined;
78  }
79
80  /// \brief Reset all of the options that are not considered when building a
81  /// module.
82  void resetNonModularOptions();
83};
84
85/// Floating point control options
86class FPOptions {
87public:
88  unsigned fp_contract : 1;
89
90  FPOptions() : fp_contract(0) {}
91
92  FPOptions(const LangOptions &LangOpts) :
93    fp_contract(LangOpts.DefaultFPContract) {}
94};
95
96/// OpenCL volatile options
97class OpenCLOptions {
98public:
99#define OPENCLEXT(nm)  unsigned nm : 1;
100#include "clang/Basic/OpenCLExtensions.def"
101
102  OpenCLOptions() {
103#define OPENCLEXT(nm)   nm = 0;
104#include "clang/Basic/OpenCLExtensions.def"
105  }
106};
107
108/// \brief Describes the kind of translation unit being processed.
109enum TranslationUnitKind {
110  /// \brief The translation unit is a complete translation unit.
111  TU_Complete,
112  /// \brief The translation unit is a prefix to a translation unit, and is
113  /// not complete.
114  TU_Prefix,
115  /// \brief The translation unit is a module.
116  TU_Module
117};
118
119  /// \brief
120}  // end namespace clang
121
122#endif
123