clang  3.7.0
LangOptions.h
Go to the documentation of this file.
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 /// \file
11 /// \brief Defines the clang::LangOptions interface.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
16 #define LLVM_CLANG_BASIC_LANGOPTIONS_H
17 
19 #include "clang/Basic/LLVM.h"
21 #include "clang/Basic/Sanitizers.h"
22 #include "clang/Basic/Visibility.h"
23 #include <string>
24 #include <vector>
25 
26 namespace clang {
27 
28 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
29 /// this large collection of bitfields is a trivial class type.
31 public:
32  // Define simple language options (with no accessors).
33 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
34 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
35 #include "clang/Basic/LangOptions.def"
36 
37 protected:
38  // Define language options of enumeration type. These are private, and will
39  // have accessors (below).
40 #define LANGOPT(Name, Bits, Default, Description)
41 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
42  unsigned Name : Bits;
43 #include "clang/Basic/LangOptions.def"
44 };
45 
46 /// \brief Keeps track of the various options that can be
47 /// enabled, which controls the dialect of C or C++ that is accepted.
48 class LangOptions : public LangOptionsBase {
49 public:
51 
54 
56  SOB_Undefined, // Default C standard behavior.
57  SOB_Defined, // -fwrapv
58  SOB_Trapping // -ftrapv
59  };
60 
66  };
67 
69 
71  MSVC2010 = 16,
72  MSVC2012 = 17,
73  MSVC2013 = 18,
74  MSVC2015 = 19
75  };
76 
77 public:
78  /// \brief Set of enabled sanitizers.
80 
81  /// \brief Paths to blacklist files specifying which objects
82  /// (files, functions, variables) should not be instrumented.
83  std::vector<std::string> SanitizerBlacklistFiles;
84 
86 
88 
89  /// \brief The name of the handler function to be called when -ftrapv is
90  /// specified.
91  ///
92  /// If none is specified, abort (GCC-compatible behaviour).
93  std::string OverflowHandler;
94 
95  /// \brief The name of the current module.
96  std::string CurrentModule;
97 
98  /// \brief The name of the module that the translation unit is an
99  /// implementation of. Prevents semantic imports, but does not otherwise
100  /// treat this as the CurrentModule.
102 
103  /// \brief The names of any features to enable in module 'requires' decls
104  /// in addition to the hard-coded list in Module.cpp and the target features.
105  ///
106  /// This list is sorted.
107  std::vector<std::string> ModuleFeatures;
108 
109  /// \brief Options for parsing comments.
111 
112  LangOptions();
113 
114  // Define accessors/mutators for language options of enumeration type.
115 #define LANGOPT(Name, Bits, Default, Description)
116 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
117  Type get##Name() const { return static_cast<Type>(Name); } \
118  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
119 #include "clang/Basic/LangOptions.def"
120 
121  bool isSignedOverflowDefined() const {
122  return getSignedOverflowBehavior() == SOB_Defined;
123  }
124 
127  !ObjCSubscriptingLegacyRuntime;
128  }
129 
130  bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
131  return MSCompatibilityVersion >= MajorVersion * 10000000U;
132  }
133 
134  /// \brief Reset all of the options that are not considered when building a
135  /// module.
136  void resetNonModularOptions();
137 };
138 
139 /// \brief Floating point control options
140 class FPOptions {
141 public:
142  unsigned fp_contract : 1;
143 
145 
146  FPOptions(const LangOptions &LangOpts) :
147  fp_contract(LangOpts.DefaultFPContract) {}
148 };
149 
150 /// \brief OpenCL volatile options
152 public:
153 #define OPENCLEXT(nm) unsigned nm : 1;
154 #include "clang/Basic/OpenCLExtensions.def"
155 
157 #define OPENCLEXT(nm) nm = 0;
158 #include "clang/Basic/OpenCLExtensions.def"
159  }
160 };
161 
162 /// \brief Describes the kind of translation unit being processed.
164  /// \brief The translation unit is a complete translation unit.
166  /// \brief The translation unit is a prefix to a translation unit, and is
167  /// not complete.
169  /// \brief The translation unit is a module.
171 };
172 
173 } // end namespace clang
174 
175 #endif
bool isSignedOverflowDefined() const
Definition: LangOptions.h:121
FPOptions(const LangOptions &LangOpts)
Definition: LangOptions.h:146
OpenCL volatile options.
Definition: LangOptions.h:151
SanitizerSet Sanitize
Set of enabled sanitizers.
Definition: LangOptions.h:79
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:168
Defines types useful for describing an Objective-C runtime.
Floating point control options.
Definition: LangOptions.h:140
unsigned fp_contract
Definition: LangOptions.h:142
Options for controlling comment parsing.
Defines the clang::SanitizerKind enum.
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
Definition: LangOptions.cpp:23
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Visibility
Describes the different kinds of visibility that a declaration may have.
Definition: Visibility.h:32
Defines the clang::Visibility enumeration and various utility functions.
std::vector< std::string > ModuleFeatures
The names of any features to enable in module 'requires' decls in addition to the hard-coded list in ...
Definition: LangOptions.h:107
std::string CurrentModule
The name of the current module.
Definition: LangOptions.h:96
CommentOptions CommentOpts
Options for parsing comments.
Definition: LangOptions.h:110
Defines the clang::CommentOptions interface.
clang::ObjCRuntime ObjCRuntime
Definition: LangOptions.h:85
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
Definition: LangOptions.h:93
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:25
std::string ImplementationOfModule
The name of the module that the translation unit is an implementation of. Prevents semantic imports...
Definition: LangOptions.h:101
bool isSubscriptPointerArithmetic() const
Is subscripting pointer arithmetic?
Definition: ObjCRuntime.h:235
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
Definition: LangOptions.h:130
bool isSubscriptPointerArithmetic() const
Definition: LangOptions.h:125
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:163
The translation unit is a complete translation unit.
Definition: LangOptions.h:165
std::vector< std::string > SanitizerBlacklistFiles
Paths to blacklist files specifying which objects (files, functions, variables) should not be instrum...
Definition: LangOptions.h:83
std::string ObjCConstantStringClass
Definition: LangOptions.h:87
clang::Visibility Visibility
Definition: LangOptions.h:50
The translation unit is a module.
Definition: LangOptions.h:170