Home | History | Annotate | Download | only in Basic
      1 //===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 //  This file defines the LangOptions interface.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #ifndef LLVM_CLANG_LANGOPTIONS_H
     15 #define LLVM_CLANG_LANGOPTIONS_H
     16 
     17 #include <string>
     18 #include "clang/Basic/Visibility.h"
     19 
     20 namespace clang {
     21 
     22 /// LangOptions - This class keeps track of the various options that can be
     23 /// enabled, which controls the dialect of C that is accepted.
     24 class LangOptions {
     25 public:
     26   typedef clang::Visibility Visibility;
     27 
     28   enum GCMode { NonGC, GCOnly, HybridGC };
     29   enum StackProtectorMode { SSPOff, SSPOn, SSPReq };
     30 
     31   enum SignedOverflowBehaviorTy {
     32     SOB_Undefined,  // Default C standard behavior.
     33     SOB_Defined,    // -fwrapv
     34     SOB_Trapping    // -ftrapv
     35   };
     36 
     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"
     41 
     42 private:
     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) \
     47   unsigned Name : Bits;
     48 #include "clang/Basic/LangOptions.def"
     49 
     50 public:
     51   std::string ObjCConstantStringClass;
     52 
     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;
     56 
     57   LangOptions();
     58 
     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"
     65 
     66   bool isSignedOverflowDefined() const {
     67     return getSignedOverflowBehavior() == SOB_Defined;
     68   }
     69 
     70   /// \brief Reset all of the options that are not considered when building a
     71   /// module.
     72   void resetNonModularOptions();
     73 };
     74 
     75 /// Floating point control options
     76 class FPOptions {
     77 public:
     78   unsigned fp_contract : 1;
     79 
     80   FPOptions() : fp_contract(0) {}
     81 
     82   FPOptions(const LangOptions &LangOpts) :
     83     fp_contract(LangOpts.DefaultFPContract) {}
     84 };
     85 
     86 /// OpenCL volatile options
     87 class OpenCLOptions {
     88 public:
     89 #define OPENCLEXT(nm)  unsigned nm : 1;
     90 #include "clang/Basic/OpenCLExtensions.def"
     91 
     92   OpenCLOptions() {
     93 #define OPENCLEXT(nm)   nm = 0;
     94 #include "clang/Basic/OpenCLExtensions.def"
     95   }
     96 };
     97 
     98 /// \brief Describes the kind of translation unit being processed.
     99 enum TranslationUnitKind {
    100   /// \brief The translation unit is a complete translation unit.
    101   TU_Complete,
    102   /// \brief The translation unit is a prefix to a translation unit, and is
    103   /// not complete.
    104   TU_Prefix,
    105   /// \brief The translation unit is a module.
    106   TU_Module
    107 };
    108 
    109   /// \brief
    110 }  // end namespace clang
    111 
    112 #endif
    113