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_LANGOPTIONS_H
16 #define LLVM_CLANG_LANGOPTIONS_H
18 #include "clang/Basic/CommentOptions.h"
19 #include "clang/Basic/LLVM.h"
20 #include "clang/Basic/ObjCRuntime.h"
21 #include "clang/Basic/Visibility.h"
22 #include "llvm/ADT/IntrusiveRefCntPtr.h"
27 struct SanitizerOptions {
28 #define SANITIZER(NAME, ID) unsigned ID : 1;
29 #include "clang/Basic/Sanitizers.def"
31 /// \brief Cached set of sanitizer options with all sanitizers disabled.
32 static const SanitizerOptions Disabled;
35 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
36 /// this large collection of bitfields is a trivial class type.
37 class LangOptionsBase {
39 // Define simple language options (with no accessors).
40 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
41 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
42 #include "clang/Basic/LangOptions.def"
44 SanitizerOptions Sanitize;
46 // Define language options of enumeration type. These are private, and will
47 // have accessors (below).
48 #define LANGOPT(Name, Bits, Default, Description)
49 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
51 #include "clang/Basic/LangOptions.def"
54 /// \brief Keeps track of the various options that can be
55 /// enabled, which controls the dialect of C or C++ that is accepted.
56 class LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase {
58 typedef clang::Visibility Visibility;
60 enum GCMode { NonGC, GCOnly, HybridGC };
61 enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
63 enum SignedOverflowBehaviorTy {
64 SOB_Undefined, // Default C standard behavior.
65 SOB_Defined, // -fwrapv
66 SOB_Trapping // -ftrapv
70 clang::ObjCRuntime ObjCRuntime;
72 std::string ObjCConstantStringClass;
74 /// \brief The name of the handler function to be called when -ftrapv is
77 /// If none is specified, abort (GCC-compatible behaviour).
78 std::string OverflowHandler;
80 /// \brief The name of the current module.
81 std::string CurrentModule;
83 /// \brief Options for parsing comments.
84 CommentOptions CommentOpts;
88 // Define accessors/mutators for language options of enumeration type.
89 #define LANGOPT(Name, Bits, Default, Description)
90 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
91 Type get##Name() const { return static_cast<Type>(Name); } \
92 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
93 #include "clang/Basic/LangOptions.def"
95 bool isSignedOverflowDefined() const {
96 return getSignedOverflowBehavior() == SOB_Defined;
99 /// \brief Reset all of the options that are not considered when building a
101 void resetNonModularOptions();
104 /// \brief Floating point control options
107 unsigned fp_contract : 1;
109 FPOptions() : fp_contract(0) {}
111 FPOptions(const LangOptions &LangOpts) :
112 fp_contract(LangOpts.DefaultFPContract) {}
115 /// \brief OpenCL volatile options
116 class OpenCLOptions {
118 #define OPENCLEXT(nm) unsigned nm : 1;
119 #include "clang/Basic/OpenCLExtensions.def"
122 #define OPENCLEXT(nm) nm = 0;
123 #include "clang/Basic/OpenCLExtensions.def"
127 /// \brief Describes the kind of translation unit being processed.
128 enum TranslationUnitKind {
129 /// \brief The translation unit is a complete translation unit.
131 /// \brief The translation unit is a prefix to a translation unit, and is
134 /// \brief The translation unit is a module.
138 } // end namespace clang