clang API Documentation
00001 //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the LangOptions interface. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_LANGOPTIONS_H 00015 #define LLVM_CLANG_LANGOPTIONS_H 00016 00017 #include <string> 00018 #include "clang/Basic/LLVM.h" 00019 #include "clang/Basic/Visibility.h" 00020 #include "llvm/ADT/IntrusiveRefCntPtr.h" 00021 00022 namespace clang { 00023 00024 /// Bitfields of LangOptions, split out from LangOptions in order to ensure that 00025 /// this large collection of bitfields is a trivial class type. 00026 class LangOptionsBase { 00027 public: 00028 // Define simple language options (with no accessors). 00029 #define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits; 00030 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) 00031 #include "clang/Basic/LangOptions.def" 00032 00033 protected: 00034 // Define language options of enumeration type. These are private, and will 00035 // have accessors (below). 00036 #define LANGOPT(Name, Bits, Default, Description) 00037 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 00038 unsigned Name : Bits; 00039 #include "clang/Basic/LangOptions.def" 00040 }; 00041 00042 /// LangOptions - This class keeps track of the various options that can be 00043 /// enabled, which controls the dialect of C that is accepted. 00044 class LangOptions : public RefCountedBase<LangOptions>, public LangOptionsBase { 00045 public: 00046 typedef clang::Visibility Visibility; 00047 00048 enum GCMode { NonGC, GCOnly, HybridGC }; 00049 enum StackProtectorMode { SSPOff, SSPOn, SSPReq }; 00050 00051 enum SignedOverflowBehaviorTy { 00052 SOB_Undefined, // Default C standard behavior. 00053 SOB_Defined, // -fwrapv 00054 SOB_Trapping // -ftrapv 00055 }; 00056 00057 public: 00058 std::string ObjCConstantStringClass; 00059 00060 /// The name of the handler function to be called when -ftrapv is specified. 00061 /// If none is specified, abort (GCC-compatible behaviour). 00062 std::string OverflowHandler; 00063 00064 /// \brief The name of the current module. 00065 std::string CurrentModule; 00066 00067 LangOptions(); 00068 00069 // Define accessors/mutators for language options of enumeration type. 00070 #define LANGOPT(Name, Bits, Default, Description) 00071 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 00072 Type get##Name() const { return static_cast<Type>(Name); } \ 00073 void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 00074 #include "clang/Basic/LangOptions.def" 00075 00076 bool isSignedOverflowDefined() const { 00077 return getSignedOverflowBehavior() == SOB_Defined; 00078 } 00079 00080 /// \brief Reset all of the options that are not considered when building a 00081 /// module. 00082 void resetNonModularOptions(); 00083 }; 00084 00085 /// Floating point control options 00086 class FPOptions { 00087 public: 00088 unsigned fp_contract : 1; 00089 00090 FPOptions() : fp_contract(0) {} 00091 00092 FPOptions(const LangOptions &LangOpts) : 00093 fp_contract(LangOpts.DefaultFPContract) {} 00094 }; 00095 00096 /// OpenCL volatile options 00097 class OpenCLOptions { 00098 public: 00099 #define OPENCLEXT(nm) unsigned nm : 1; 00100 #include "clang/Basic/OpenCLExtensions.def" 00101 00102 OpenCLOptions() { 00103 #define OPENCLEXT(nm) nm = 0; 00104 #include "clang/Basic/OpenCLExtensions.def" 00105 } 00106 }; 00107 00108 /// \brief Describes the kind of translation unit being processed. 00109 enum TranslationUnitKind { 00110 /// \brief The translation unit is a complete translation unit. 00111 TU_Complete, 00112 /// \brief The translation unit is a prefix to a translation unit, and is 00113 /// not complete. 00114 TU_Prefix, 00115 /// \brief The translation unit is a module. 00116 TU_Module 00117 }; 00118 00119 /// \brief 00120 } // end namespace clang 00121 00122 #endif