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/Visibility.h"
22 /// LangOptions - This class keeps track of the various options that can be
23 /// enabled, which controls the dialect of C that is accepted.
26 typedef clang::Visibility Visibility;
28 enum GCMode { NonGC, GCOnly, HybridGC };
29 enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
31 enum SignedOverflowBehaviorTy {
32 SOB_Undefined, // Default C standard behavior.
33 SOB_Defined, // -fwrapv
34 SOB_Trapping // -ftrapv
37 // Define simple language options (with no accessors).
38 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits;
39 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description)
40 #include "clang/Basic/LangOptions.def"
43 // Define language options of enumeration type. These are private, and will
44 // have accessors (below).
45 #define LANGOPT(Name, Bits, Default, Description)
46 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
48 #include "clang/Basic/LangOptions.def"
51 std::string ObjCConstantStringClass;
53 /// The name of the handler function to be called when -ftrapv is specified.
54 /// If none is specified, abort (GCC-compatible behaviour).
55 std::string OverflowHandler;
59 // Define accessors/mutators for language options of enumeration type.
60 #define LANGOPT(Name, Bits, Default, Description)
61 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
62 Type get##Name() const { return static_cast<Type>(Name); } \
63 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
64 #include "clang/Basic/LangOptions.def"
66 bool isSignedOverflowDefined() const {
67 return getSignedOverflowBehavior() == SOB_Defined;
70 /// \brief Reset all of the options that are not considered when building a
72 void resetNonModularOptions();
75 /// Floating point control options
78 unsigned fp_contract : 1;
80 FPOptions() : fp_contract(0) {}
82 FPOptions(const LangOptions &LangOpts) :
83 fp_contract(LangOpts.DefaultFPContract) {}
86 /// OpenCL volatile options
89 #define OPENCLEXT(nm) unsigned nm : 1;
90 #include "clang/Basic/OpenCLExtensions.def"
93 #define OPENCLEXT(nm) nm = 0;
94 #include "clang/Basic/OpenCLExtensions.def"
98 /// \brief Describes the kind of translation unit being processed.
99 enum TranslationUnitKind {
100 /// \brief The translation unit is a complete translation unit.
102 /// \brief The translation unit is a prefix to a translation unit, and is
105 /// \brief The translation unit is a module.
110 } // end namespace clang