1 //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines the clang::LangOptions interface.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_BASIC_LANGOPTIONS_H
16 #define LLVM_CLANG_BASIC_LANGOPTIONS_H
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"
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 {
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"
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) \
42 #include "clang/Basic/LangOptions.def"
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 {
49 typedef clang::Visibility Visibility;
51 enum GCMode { NonGC, GCOnly, HybridGC };
52 enum StackProtectorMode { SSPOff, SSPOn, SSPStrong, SSPReq };
54 enum SignedOverflowBehaviorTy {
55 SOB_Undefined, // Default C standard behavior.
56 SOB_Defined, // -fwrapv
57 SOB_Trapping // -ftrapv
60 enum PragmaMSPointersToMembersKind {
62 PPTMK_FullGeneralitySingleInheritance,
63 PPTMK_FullGeneralityMultipleInheritance,
64 PPTMK_FullGeneralityVirtualInheritance
67 enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off };
70 /// \brief Set of enabled sanitizers.
71 SanitizerSet Sanitize;
73 /// \brief Path to blacklist file specifying which objects
74 /// (files, functions, variables) should not be instrumented.
75 std::string SanitizerBlacklistFile;
77 clang::ObjCRuntime ObjCRuntime;
79 std::string ObjCConstantStringClass;
81 /// \brief The name of the handler function to be called when -ftrapv is
84 /// If none is specified, abort (GCC-compatible behaviour).
85 std::string OverflowHandler;
87 /// \brief The name of the current module.
88 std::string CurrentModule;
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;
95 /// \brief Options for parsing comments.
96 CommentOptions CommentOpts;
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"
107 bool isSignedOverflowDefined() const {
108 return getSignedOverflowBehavior() == SOB_Defined;
111 bool isSubscriptPointerArithmetic() const {
112 return ObjCRuntime.isSubscriptPointerArithmetic() &&
113 !ObjCSubscriptingLegacyRuntime;
116 /// \brief Reset all of the options that are not considered when building a
118 void resetNonModularOptions();
121 /// \brief Floating point control options
124 unsigned fp_contract : 1;
126 FPOptions() : fp_contract(0) {}
128 FPOptions(const LangOptions &LangOpts) :
129 fp_contract(LangOpts.DefaultFPContract) {}
132 /// \brief OpenCL volatile options
133 class OpenCLOptions {
135 #define OPENCLEXT(nm) unsigned nm : 1;
136 #include "clang/Basic/OpenCLExtensions.def"
139 #define OPENCLEXT(nm) nm = 0;
140 #include "clang/Basic/OpenCLExtensions.def"
144 /// \brief Describes the kind of translation unit being processed.
145 enum TranslationUnitKind {
146 /// \brief The translation unit is a complete translation unit.
148 /// \brief The translation unit is a prefix to a translation unit, and is
151 /// \brief The translation unit is a module.
155 } // end namespace clang