Coverage Report

Created: 2018-07-22 10:17

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Basic/LangOptions.h
Line
Count
Source (jump to first uncovered line)
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
/// Defines the clang::LangOptions interface.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
16
#define LLVM_CLANG_BASIC_LANGOPTIONS_H
17
18
#include "clang/Basic/CommentOptions.h"
19
#include "clang/Basic/LLVM.h"
20
#include "clang/Basic/ObjCRuntime.h"
21
#include "clang/Basic/Sanitizers.h"
22
#include "clang/Basic/Visibility.h"
23
#include "llvm/ADT/StringRef.h"
24
#include "llvm/ADT/Triple.h"
25
#include <string>
26
#include <vector>
27
28
namespace clang {
29
30
/// Bitfields of LangOptions, split out from LangOptions in order to ensure that
31
/// this large collection of bitfields is a trivial class type.
32
class LangOptionsBase {
33
public:
34
  // Define simple language options (with no accessors).
35
#define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
36
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
37
#include "clang/Basic/LangOptions.def"
38
39
protected:
40
  // Define language options of enumeration type. These are private, and will
41
  // have accessors (below).
42
#define LANGOPT(Name, Bits, Default, Description)
43
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
44
  unsigned Name : Bits;
45
#include "clang/Basic/LangOptions.def"
46
};
47
48
/// Keeps track of the various options that can be
49
/// enabled, which controls the dialect of C or C++ that is accepted.
50
class LangOptions : public LangOptionsBase {
51
public:
52
  using Visibility = clang::Visibility;
53
  
54
  enum GCMode { NonGC, GCOnly, HybridGC };
55
  enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
56
  
57
  enum SignedOverflowBehaviorTy {
58
    // Default C standard behavior.
59
    SOB_Undefined,
60
61
    // -fwrapv
62
    SOB_Defined,
63
64
    // -ftrapv
65
    SOB_Trapping
66
  };
67
68
  // FIXME: Unify with TUKind.
69
  enum CompilingModuleKind {
70
    /// Not compiling a module interface at all.
71
    CMK_None,
72
73
    /// Compiling a module from a module map.
74
    CMK_ModuleMap,
75
76
    /// Compiling a C++ modules TS module interface unit.
77
    CMK_ModuleInterface
78
  };
79
80
  enum PragmaMSPointersToMembersKind {
81
    PPTMK_BestCase,
82
    PPTMK_FullGeneralitySingleInheritance,
83
    PPTMK_FullGeneralityMultipleInheritance,
84
    PPTMK_FullGeneralityVirtualInheritance
85
  };
86
87
  enum DefaultCallingConvention {
88
    DCC_None,
89
    DCC_CDecl,
90
    DCC_FastCall,
91
    DCC_StdCall,
92
    DCC_VectorCall,
93
    DCC_RegCall
94
  };
95
96
  enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
97
98
  enum MSVCMajorVersion {
99
    MSVC2010 = 16,
100
    MSVC2012 = 17,
101
    MSVC2013 = 18,
102
    MSVC2015 = 19
103
  };
104
105
  /// Clang versions with different platform ABI conformance.
106
  enum class ClangABI {
107
    /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
108
    /// (SVN r257626). This causes <1 x long long> to be passed in an
109
    /// integer register instead of an SSE register on x64_64.
110
    Ver3_8,
111
112
    /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
113
    /// (SVN r291814). This causes move operations to be ignored when
114
    /// determining whether a class type can be passed or returned directly.
115
    Ver4,
116
117
    /// Attempt to be ABI-compatible with code generated by Clang 6.0.x
118
    /// (SVN r321711). This causes determination of whether a type is
119
    /// standard-layout to ignore collisions between empty base classes
120
    /// and between base classes and member subobjects, which affects
121
    /// whether we reuse base class tail padding in some ABIs.
122
    Ver6,
123
124
    /// Conform to the underlying platform's C and C++ ABIs as closely
125
    /// as we can.
126
    Latest
127
  };
128
129
  enum FPContractModeKind {
130
    // Form fused FP ops only where result will not be affected.
131
    FPC_Off,
132
133
    // Form fused FP ops according to FP_CONTRACT rules.
134
    FPC_On,
135
136
    // Aggressively fuse FP ops (E.g. FMA).
137
    FPC_Fast
138
  };
139
140
public:
141
  /// Set of enabled sanitizers.
142
  SanitizerSet Sanitize;
143
144
  /// Paths to blacklist files specifying which objects
145
  /// (files, functions, variables) should not be instrumented.
146
  std::vector<std::string> SanitizerBlacklistFiles;
147
148
  /// Paths to the XRay "always instrument" files specifying which
149
  /// objects (files, functions, variables) should be imbued with the XRay
150
  /// "always instrument" attribute.
151
  /// WARNING: This is a deprecated field and will go away in the future.
152
  std::vector<std::string> XRayAlwaysInstrumentFiles;
153
154
  /// Paths to the XRay "never instrument" files specifying which
155
  /// objects (files, functions, variables) should be imbued with the XRay
156
  /// "never instrument" attribute.
157
  /// WARNING: This is a deprecated field and will go away in the future.
158
  std::vector<std::string> XRayNeverInstrumentFiles;
159
160
  /// Paths to the XRay attribute list files, specifying which objects
161
  /// (files, functions, variables) should be imbued with the appropriate XRay
162
  /// attribute(s).
163
  std::vector<std::string> XRayAttrListFiles;
164
165
  clang::ObjCRuntime ObjCRuntime;
166
167
  std::string ObjCConstantStringClass;
168
  
169
  /// The name of the handler function to be called when -ftrapv is
170
  /// specified.
171
  ///
172
  /// If none is specified, abort (GCC-compatible behaviour).
173
  std::string OverflowHandler;
174
175
  /// The module currently being compiled as speficied by -fmodule-name.
176
  std::string ModuleName;
177
178
  /// The name of the current module, of which the main source file
179
  /// is a part. If CompilingModule is set, we are compiling the interface
180
  /// of this module, otherwise we are compiling an implementation file of
181
  /// it. This starts as ModuleName in case -fmodule-name is provided and
182
  /// changes during compilation to reflect the current module.
183
  std::string CurrentModule;
184
185
  /// The names of any features to enable in module 'requires' decls
186
  /// in addition to the hard-coded list in Module.cpp and the target features.
187
  ///
188
  /// This list is sorted.
189
  std::vector<std::string> ModuleFeatures;
190
191
  /// Options for parsing comments.
192
  CommentOptions CommentOpts;
193
194
  /// A list of all -fno-builtin-* function names (e.g., memset).
195
  std::vector<std::string> NoBuiltinFuncs;
196
197
  /// Triples of the OpenMP targets that the host code codegen should
198
  /// take into account in order to generate accurate offloading descriptors.
199
  std::vector<llvm::Triple> OMPTargetTriples;
200
201
  /// Name of the IR file that contains the result of the OpenMP target
202
  /// host code generation.
203
  std::string OMPHostIRFile;
204
205
  /// Indicates whether the front-end is explicitly told that the
206
  /// input is a header file (i.e. -x c-header).
207
  bool IsHeaderFile = false;
208
209
  LangOptions();
210
211
  // Define accessors/mutators for language options of enumeration type.
212
#define LANGOPT(Name, Bits, Default, Description) 
213
#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
214
63.4M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getCompilingModule() const
Line
Count
Source
214
39.4M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getMSPointerToMemberRepresentationMethod() const
Line
Count
Source
214
49.8k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getDefaultCallingConv() const
Line
Count
Source
214
4.35M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getDefaultFPContractMode() const
Line
Count
Source
214
70.3k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getAddressSpaceMapMangling() const
Line
Count
Source
214
49.9k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getGC() const
Line
Count
Source
214
12.3M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getValueVisibilityMode() const
Line
Count
Source
214
1.10M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getTypeVisibilityMode() const
Line
Count
Source
214
526k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getStackProtector() const
Line
Count
Source
214
888k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getSignedOverflowBehavior() const
Line
Count
Source
214
535k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::LangOptions::getClangABICompat() const
Line
Count
Source
214
4.01M
  Type get##Name() const { return static_cast<Type>(Name); } \
215
10.7M
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setCompilingModule(clang::LangOptions::CompilingModuleKind)
Line
Count
Source
215
1.00M
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setMSPointerToMemberRepresentationMethod(clang::LangOptions::PragmaMSPointersToMembersKind)
Line
Count
Source
215
962k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setDefaultCallingConv(clang::LangOptions::DefaultCallingConvention)
Line
Count
Source
215
962k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setDefaultFPContractMode(clang::LangOptions::FPContractModeKind)
Line
Count
Source
215
963k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setAddressSpaceMapMangling(clang::LangOptions::AddrSpaceMapMangling)
Line
Count
Source
215
962k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setGC(clang::LangOptions::GCMode)
Line
Count
Source
215
962k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setValueVisibilityMode(clang::Visibility)
Line
Count
Source
215
998k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setTypeVisibilityMode(clang::Visibility)
Line
Count
Source
215
998k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setStackProtector(clang::LangOptions::StackProtectorMode)
Line
Count
Source
215
998k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setSignedOverflowBehavior(clang::LangOptions::SignedOverflowBehaviorTy)
Line
Count
Source
215
962k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
clang::LangOptions::setClangABICompat(clang::LangOptions::ClangABI)
Line
Count
Source
215
962k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
216
#include "clang/Basic/LangOptions.def"
217
218
  /// Are we compiling a module interface (.cppm or module map)?
219
39.4M
  bool isCompilingModule() const {
220
39.4M
    return getCompilingModule() != CMK_None;
221
39.4M
  }
222
223
  /// Do we need to track the owning module for a local declaration?
224
38.8M
  bool trackLocalOwningModule() const {
225
38.8M
    return isCompilingModule() || 
ModulesLocalVisibility38.5M
||
ModulesTS38.5M
;
226
38.8M
  }
227
228
251k
  bool isSignedOverflowDefined() const {
229
251k
    return getSignedOverflowBehavior() == SOB_Defined;
230
251k
  }
231
  
232
263
  bool isSubscriptPointerArithmetic() const {
233
263
    return ObjCRuntime.isSubscriptPointerArithmetic() &&
234
263
           
!ObjCSubscriptingLegacyRuntime11
;
235
263
  }
236
237
40.3k
  bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const {
238
40.3k
    return MSCompatibilityVersion >= MajorVersion * 10000000U;
239
40.3k
  }
240
241
  /// Reset all of the options that are not considered when building a
242
  /// module.
243
  void resetNonModularOptions();
244
245
  /// Is this a libc/libm function that is no longer recognized as a
246
  /// builtin because a -fno-builtin-* option has been specified?
247
  bool isNoBuiltinFunc(StringRef Name) const;
248
249
  /// True if any ObjC types may have non-trivial lifetime qualifiers.
250
6.71M
  bool allowsNonTrivialObjCLifetimeQualifiers() const {
251
6.71M
    return ObjCAutoRefCount || 
ObjCWeak6.70M
;
252
6.71M
  }
253
254
1.23M
  bool assumeFunctionsAreConvergent() const {
255
1.23M
    return (CUDA && 
CUDAIsDevice610
) ||
OpenCL1.23M
;
256
1.23M
  }
257
258
  /// Return the OpenCL C or C++ version as a VersionTuple.
259
  VersionTuple getOpenCLVersionTuple() const;
260
};
261
262
/// Floating point control options
263
0
class FPOptions {
264
public:
265
642k
  FPOptions() : fp_contract(LangOptions::FPC_Off) {}
266
267
  // Used for serializing.
268
  explicit FPOptions(unsigned I)
269
1.58M
      : fp_contract(static_cast<LangOptions::FPContractModeKind>(I)) {}
270
271
  explicit FPOptions(const LangOptions &LangOpts)
272
36.4k
      : fp_contract(LangOpts.getDefaultFPContractMode()) {}
273
274
34.4k
  bool allowFPContractWithinStatement() const {
275
34.4k
    return fp_contract == LangOptions::FPC_On;
276
34.4k
  }
277
278
45.1k
  bool allowFPContractAcrossStatement() const {
279
45.1k
    return fp_contract == LangOptions::FPC_Fast;
280
45.1k
  }
281
282
17
  void setAllowFPContractWithinStatement() {
283
17
    fp_contract = LangOptions::FPC_On;
284
17
  }
285
286
6
  void setAllowFPContractAcrossStatement() {
287
6
    fp_contract = LangOptions::FPC_Fast;
288
6
  }
289
290
74
  void setDisallowFPContract() { fp_contract = LangOptions::FPC_Off; }
291
292
  /// Used to serialize this.
293
6.48M
  unsigned getInt() const { return fp_contract; }
294
295
private:
296
  /// Adjust BinaryOperator::FPFeatures to match the bit-field size of this.
297
  unsigned fp_contract : 2;
298
};
299
300
/// Describes the kind of translation unit being processed.
301
enum TranslationUnitKind {
302
  /// The translation unit is a complete translation unit.
303
  TU_Complete,
304
305
  /// The translation unit is a prefix to a translation unit, and is
306
  /// not complete.
307
  TU_Prefix,
308
309
  /// The translation unit is a module.
310
  TU_Module
311
};
312
  
313
} // namespace clang
314
315
#endif // LLVM_CLANG_BASIC_LANGOPTIONS_H