LangOptions.h revision b86b8dc7ef89405205f94635c1073cdb1a7093eb
15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- LangOptions.h - C Language Family Language Options -----*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 95f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// This file defines the LangOptions interface. 115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 125f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_LANGOPTIONS_H 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_LANGOPTIONS_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 171b0969590e712d7d52fc9c0d43d3ab85c36d07a6Daniel Dunbar#include <string> 181fb0caaa7bef765b85972274e3b434af2572c141John McCall#include "clang/Basic/Visibility.h" 191b0969590e712d7d52fc9c0d43d3ab85c36d07a6Daniel Dunbar 205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 221b27ab31526b91b165f153a8ca3928c59e1b13c9Ted Kremenek/// LangOptions - This class keeps track of the various options that can be 231b27ab31526b91b165f153a8ca3928c59e1b13c9Ted Kremenek/// enabled, which controls the dialect of C that is accepted. 241b27ab31526b91b165f153a8ca3928c59e1b13c9Ted Kremenekclass LangOptions { 25ea684e699ea84e61711e279f5fa7a1b9f3d46bc2Cedric Venetpublic: 267d5e81bf24dbfd334a7c62a7ae51043c79a69aa9Douglas Gregor typedef clang::Visibility Visibility; 277d5e81bf24dbfd334a7c62a7ae51043c79a69aa9Douglas Gregor 2801d9dbf4ae627e2ba42fc23485789a33fa296516Ted Kremenek enum GCMode { NonGC, GCOnly, HybridGC }; 294ebe3e4c811a376c423a544f5e76ee2e96533324Bill Wendling enum StackProtectorMode { SSPOff, SSPOn, SSPReq }; 30e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 31a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner enum SignedOverflowBehaviorTy { 32a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner SOB_Undefined, // Default C standard behavior. 33a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner SOB_Defined, // -fwrapv 34a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner SOB_Trapping // -ftrapv 35a4d71455f0d418e16cc0c5c5aa55a3bad3494aeeChris Lattner }; 36e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 37e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor // Define simple language options (with no accessors). 38e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#define LANGOPT(Name, Bits, Default, Description) unsigned Name : Bits; 39e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) 40e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#include "clang/Basic/LangOptions.def" 41e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 42e289d81369914678db386f6aa86faf8f178e245dDouglas Gregorprivate: 43e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor // Define language options of enumeration type. These are private, and will 44e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor // have accessors (below). 45e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#define LANGOPT(Name, Bits, Default, Description) 46e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 47e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor unsigned Name : Bits; 48e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#include "clang/Basic/LangOptions.def" 49e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 50e289d81369914678db386f6aa86faf8f178e245dDouglas Gregorpublic: 51e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor std::string ObjCConstantStringClass; 52e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 537f18e67e1b577a50402e8b43508ab2311a5c45b5David Chisnall /// The name of the handler function to be called when -ftrapv is specified. 547f18e67e1b577a50402e8b43508ab2311a5c45b5David Chisnall /// If none is specified, abort (GCC-compatible behaviour). 557f18e67e1b577a50402e8b43508ab2311a5c45b5David Chisnall std::string OverflowHandler; 561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 57b86b8dc7ef89405205f94635c1073cdb1a7093ebDouglas Gregor /// \brief The name of the current module. 58b86b8dc7ef89405205f94635c1073cdb1a7093ebDouglas Gregor std::string CurrentModule; 59b86b8dc7ef89405205f94635c1073cdb1a7093ebDouglas Gregor 60e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor LangOptions(); 612cb4222338669a3e70b546ef264fbd5d3f96aef5Chris Lattner 62e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor // Define accessors/mutators for language options of enumeration type. 63e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#define LANGOPT(Name, Bits, Default, Description) 64e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ 65e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor Type get##Name() const { return static_cast<Type>(Name); } \ 66e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor void set##Name(Type Value) { Name = static_cast<unsigned>(Value); } 67e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor#include "clang/Basic/LangOptions.def" 68e289d81369914678db386f6aa86faf8f178e245dDouglas Gregor 692cb4222338669a3e70b546ef264fbd5d3f96aef5Chris Lattner bool isSignedOverflowDefined() const { 702cb4222338669a3e70b546ef264fbd5d3f96aef5Chris Lattner return getSignedOverflowBehavior() == SOB_Defined; 712cb4222338669a3e70b546ef264fbd5d3f96aef5Chris Lattner } 721c7e0472f5683a8ade62285f366637050cf113e5Douglas Gregor 731c7e0472f5683a8ade62285f366637050cf113e5Douglas Gregor /// \brief Reset all of the options that are not considered when building a 741c7e0472f5683a8ade62285f366637050cf113e5Douglas Gregor /// module. 751c7e0472f5683a8ade62285f366637050cf113e5Douglas Gregor void resetNonModularOptions(); 765f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 775f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 78321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne/// Floating point control options 79321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourneclass FPOptions { 80321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbournepublic: 81321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne unsigned fp_contract : 1; 82321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne 83321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne FPOptions() : fp_contract(0) {} 84321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne 85321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne FPOptions(const LangOptions &LangOpts) : 86321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne fp_contract(LangOpts.DefaultFPContract) {} 87321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne}; 88321b8179afaf803dcc56b2a19f7b0891a03c92c8Peter Collingbourne 89f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne/// OpenCL volatile options 90f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourneclass OpenCLOptions { 91f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbournepublic: 92f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne#define OPENCLEXT(nm) unsigned nm : 1; 93f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne#include "clang/Basic/OpenCLExtensions.def" 94f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne 95f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne OpenCLOptions() { 96f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne#define OPENCLEXT(nm) nm = 0; 97f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne#include "clang/Basic/OpenCLExtensions.def" 98f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne } 99f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne}; 100f315fa81eef1977b3457fd7a7d4639e060fe7278Peter Collingbourne 101467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor/// \brief Describes the kind of translation unit being processed. 102467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregorenum TranslationUnitKind { 103467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor /// \brief The translation unit is a complete translation unit. 104467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor TU_Complete, 105467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor /// \brief The translation unit is a prefix to a translation unit, and is 106467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor /// not complete. 107467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor TU_Prefix, 108467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor /// \brief The translation unit is a module. 109467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor TU_Module 110467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor}; 111467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor 112467dc88512b4ba4bb16e274ea3771dc1415d31daDouglas Gregor /// \brief 1135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 1145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 116