clang  3.9.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 
74  };
75 
77 
79  MSVC2010 = 16,
80  MSVC2012 = 17,
81  MSVC2013 = 18,
82  MSVC2015 = 19
83  };
84 
85 public:
86  /// \brief Set of enabled sanitizers.
88 
89  /// \brief Paths to blacklist files specifying which objects
90  /// (files, functions, variables) should not be instrumented.
91  std::vector<std::string> SanitizerBlacklistFiles;
92 
94 
96 
97  /// \brief The name of the handler function to be called when -ftrapv is
98  /// specified.
99  ///
100  /// If none is specified, abort (GCC-compatible behaviour).
101  std::string OverflowHandler;
102 
103  /// \brief The name of the current module, of which the main source file
104  /// is a part. If CompilingModule is set, we are compiling the interface
105  /// of this module, otherwise we are compiling an implementation file of
106  /// it.
107  std::string CurrentModule;
108 
109  /// \brief The names of any features to enable in module 'requires' decls
110  /// in addition to the hard-coded list in Module.cpp and the target features.
111  ///
112  /// This list is sorted.
113  std::vector<std::string> ModuleFeatures;
114 
115  /// \brief Options for parsing comments.
117 
118  /// \brief A list of all -fno-builtin-* function names (e.g., memset).
119  std::vector<std::string> NoBuiltinFuncs;
120 
121  /// \brief Triples of the OpenMP targets that the host code codegen should
122  /// take into account in order to generate accurate offloading descriptors.
123  std::vector<llvm::Triple> OMPTargetTriples;
124 
125  /// \brief Name of the IR file that contains the result of the OpenMP target
126  /// host code generation.
127  std::string OMPHostIRFile;
128 
129  LangOptions();
130 
131  // Define accessors/mutators for language options of enumeration type.
132 #define LANGOPT(Name, Bits, Default, Description)
133 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
134  Type get##Name() const { return static_cast<Type>(Name); } \
135  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
136 #include "clang/Basic/LangOptions.def"
137 
138  bool isSignedOverflowDefined() const {
139  return getSignedOverflowBehavior() == SOB_Defined;
140  }
141 
144  !ObjCSubscriptingLegacyRuntime;
145  }
146 
147  bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
148  return MSCompatibilityVersion >= MajorVersion * 10000000U;
149  }
150 
151  /// \brief Reset all of the options that are not considered when building a
152  /// module.
153  void resetNonModularOptions();
154 
155  /// \brief Is this a libc/libm function that is no longer recognized as a
156  /// builtin because a -fno-builtin-* option has been specified?
157  bool isNoBuiltinFunc(const char *Name) const;
158 };
159 
160 /// \brief Floating point control options
161 class FPOptions {
162 public:
163  unsigned fp_contract : 1;
164 
166 
167  FPOptions(const LangOptions &LangOpts) :
168  fp_contract(LangOpts.DefaultFPContract) {}
169 };
170 
171 /// \brief Describes the kind of translation unit being processed.
173  /// \brief The translation unit is a complete translation unit.
175  /// \brief The translation unit is a prefix to a translation unit, and is
176  /// not complete.
178  /// \brief The translation unit is a module.
180 };
181 
182 } // end namespace clang
183 
184 #endif
bool isSignedOverflowDefined() const
Definition: LangOptions.h:138
FPOptions(const LangOptions &LangOpts)
Definition: LangOptions.h:167
SanitizerSet Sanitize
Set of enabled sanitizers.
Definition: LangOptions.h:87
The translation unit is a prefix to a translation unit, and is not complete.
Definition: LangOptions.h:177
Defines types useful for describing an Objective-C runtime.
Floating point control options.
Definition: LangOptions.h:161
unsigned fp_contract
Definition: LangOptions.h:163
Options for controlling comment parsing.
Defines the clang::SanitizerKind enum.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Definition: Type.h:4549
bool isNoBuiltinFunc(const char *Name) const
Is this a libc/libm function that is no longer recognized as a builtin because a -fno-builtin-* optio...
Definition: LangOptions.cpp:39
void resetNonModularOptions()
Reset all of the options that are not considered when building a module.
Definition: LangOptions.cpp:24
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:113
std::string CurrentModule
The name of the current module, of which the main source file is a part.
Definition: LangOptions.h:107
CommentOptions CommentOpts
Options for parsing comments.
Definition: LangOptions.h:116
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Definition: LangOptions.h:127
Defines the clang::CommentOptions interface.
clang::ObjCRuntime ObjCRuntime
Definition: LangOptions.h:93
std::string OverflowHandler
The name of the handler function to be called when -ftrapv is specified.
Definition: LangOptions.h:101
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:25
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
Definition: LangOptions.h:123
bool isSubscriptPointerArithmetic() const
Is subscripting pointer arithmetic?
Definition: ObjCRuntime.h:249
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
Definition: LangOptions.h:147
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
Definition: LangOptions.h:119
bool isSubscriptPointerArithmetic() const
Definition: LangOptions.h:142
TranslationUnitKind
Describes the kind of translation unit being processed.
Definition: LangOptions.h:172
The translation unit is a complete translation unit.
Definition: LangOptions.h:174
std::vector< std::string > SanitizerBlacklistFiles
Paths to blacklist files specifying which objects (files, functions, variables) should not be instrum...
Definition: LangOptions.h:91
Bitfields of LangOptions, split out from LangOptions in order to ensure that this large collection of...
Definition: LangOptions.h:30
std::string ObjCConstantStringClass
Definition: LangOptions.h:95
clang::Visibility Visibility
Definition: LangOptions.h:50
The translation unit is a module.
Definition: LangOptions.h:179