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 //===----------------------------------------------------------------------===//
10 // This file defines the LangOptions interface.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_LANGOPTIONS_H
15 #define LLVM_CLANG_LANGOPTIONS_H
18 #include "clang/Basic/LLVM.h"
19 #include "clang/Basic/Visibility.h"
20 #include "llvm/ADT/IntrusiveRefCntPtr.h"
24 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that
25 /// this large collection of bitfields is a trivial class type.
26 class LangOptionsBase {
28 // Define simple language options (with no accessors).
29 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
30 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
31 #include "clang/Basic/LangOptions.def"
34 // Define language options of enumeration type. These are private, and will
35 // have accessors (below).
36 #define LANGOPT(Name, Bits, Default, Description)
37 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
39 #include "clang/Basic/LangOptions.def"
42 /// LangOptions - This class keeps track of the various options that can be
43 /// enabled, which controls the dialect of C that is accepted.
44 class LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase {
46 typedef clang::Visibility Visibility;
48 enum GCMode { NonGC, GCOnly, HybridGC };
49 enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
51 enum SignedOverflowBehaviorTy {
52 SOB_Undefined, // Default C standard behavior.
53 SOB_Defined, // -fwrapv
54 SOB_Trapping // -ftrapv
58 std::string ObjCConstantStringClass;
60 /// The name of the handler function to be called when -ftrapv is specified.
61 /// If none is specified, abort (GCC-compatible behaviour).
62 std::string OverflowHandler;
64 /// \brief The name of the current module.
65 std::string CurrentModule;
69 // Define accessors/mutators for language options of enumeration type.
70 #define LANGOPT(Name, Bits, Default, Description)
71 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
72 Type get##Name() const { return static_cast<Type>(Name); } \
73 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
74 #include "clang/Basic/LangOptions.def"
76 bool isSignedOverflowDefined() const {
77 return getSignedOverflowBehavior() == SOB_Defined;
80 /// \brief Reset all of the options that are not considered when building a
82 void resetNonModularOptions();
85 /// Floating point control options
88 unsigned fp_contract : 1;
90 FPOptions() : fp_contract(0) {}
92 FPOptions(const LangOptions &LangOpts) :
93 fp_contract(LangOpts.DefaultFPContract) {}
96 /// OpenCL volatile options
99 #define OPENCLEXT(nm) unsigned nm : 1;
100 #include "clang/Basic/OpenCLExtensions.def"
103 #define OPENCLEXT(nm) nm = 0;
104 #include "clang/Basic/OpenCLExtensions.def"
108 /// \brief Describes the kind of translation unit being processed.
109 enum TranslationUnitKind {
110 /// \brief The translation unit is a complete translation unit.
112 /// \brief The translation unit is a prefix to a translation unit, and is
115 /// \brief The translation unit is a module.
120 } // end namespace clang