]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/LangOptions.h
Update compiler-rt to trunk r230183. This has some of our patches
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / LangOptions.h
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
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 <string>
24
25 namespace clang {
26
27 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
28 /// this large collection of bitfields is a trivial class type.
29 class LangOptionsBase {
30 public:
31   // Define simple language options (with no accessors).
32 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
33 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
34 #include "clang/Basic/LangOptions.def"
35
36 protected:
37   // Define language options of enumeration type. These are private, and will
38   // have accessors (below).
39 #define LANGOPT(Name, Bits, Default, Description)
40 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
41   unsigned Name : Bits;
42 #include "clang/Basic/LangOptions.def"
43 };
44
45 /// \brief Keeps track of the various options that can be
46 /// enabled, which controls the dialect of C or C++ that is accepted.
47 class LangOptions : public LangOptionsBase {
48 public:
49   typedef clang::Visibility Visibility;
50   
51   enum GCMode { NonGC, GCOnly, HybridGC };
52   enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
53   
54   enum SignedOverflowBehaviorTy {
55     SOB_Undefined,  // Default C standard behavior.
56     SOB_Defined,    // -fwrapv
57     SOB_Trapping    // -ftrapv
58   };
59
60   enum PragmaMSPointersToMembersKind {
61     PPTMK_BestCase,
62     PPTMK_FullGeneralitySingleInheritance,
63     PPTMK_FullGeneralityMultipleInheritance,
64     PPTMK_FullGeneralityVirtualInheritance
65   };
66
67   enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
68
69 public:
70   /// \brief Set of enabled sanitizers.
71   SanitizerSet Sanitize;
72
73   /// \brief Path to blacklist file specifying which objects
74   /// (files, functions, variables) should not be instrumented.
75   std::string SanitizerBlacklistFile;
76
77   clang::ObjCRuntime ObjCRuntime;
78
79   std::string ObjCConstantStringClass;
80   
81   /// \brief The name of the handler function to be called when -ftrapv is
82   /// specified.
83   ///
84   /// If none is specified, abort (GCC-compatible behaviour).
85   std::string OverflowHandler;
86
87   /// \brief The name of the current module.
88   std::string CurrentModule;
89
90   /// \brief The name of the module that the translation unit is an
91   /// implementation of. Prevents semantic imports, but does not otherwise
92   /// treat this as the CurrentModule.
93   std::string ImplementationOfModule;
94
95   /// \brief Options for parsing comments.
96   CommentOptions CommentOpts;
97   
98   LangOptions();
99
100   // Define accessors/mutators for language options of enumeration type.
101 #define LANGOPT(Name, Bits, Default, Description) 
102 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
103   Type get##Name() const { return static_cast<Type>(Name); } \
104   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }  
105 #include "clang/Basic/LangOptions.def"
106   
107   bool isSignedOverflowDefined() const {
108     return getSignedOverflowBehavior() == SOB_Defined;
109   }
110   
111   bool isSubscriptPointerArithmetic() const {
112     return ObjCRuntime.isSubscriptPointerArithmetic() &&
113            !ObjCSubscriptingLegacyRuntime;
114   }
115
116   /// \brief Reset all of the options that are not considered when building a
117   /// module.
118   void resetNonModularOptions();
119 };
120
121 /// \brief Floating point control options
122 class FPOptions {
123 public:
124   unsigned fp_contract : 1;
125
126   FPOptions() : fp_contract(0) {}
127
128   FPOptions(const LangOptions &LangOpts) :
129     fp_contract(LangOpts.DefaultFPContract) {}
130 };
131
132 /// \brief OpenCL volatile options
133 class OpenCLOptions {
134 public:
135 #define OPENCLEXT(nm)  unsigned nm : 1;
136 #include "clang/Basic/OpenCLExtensions.def"
137
138   OpenCLOptions() {
139 #define OPENCLEXT(nm)   nm = 0;
140 #include "clang/Basic/OpenCLExtensions.def"
141   }
142 };
143
144 /// \brief Describes the kind of translation unit being processed.
145 enum TranslationUnitKind {
146   /// \brief The translation unit is a complete translation unit.
147   TU_Complete,
148   /// \brief The translation unit is a prefix to a translation unit, and is
149   /// not complete.
150   TU_Prefix,
151   /// \brief The translation unit is a module.
152   TU_Module
153 };
154   
155 }  // end namespace clang
156
157 #endif