clang API Documentation

LangStandard.h
Go to the documentation of this file.
00001 //===--- LangStandard.h -----------------------------------------*- 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 #ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H
00011 #define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
00012 
00013 #include "clang/Basic/LLVM.h"
00014 #include "llvm/ADT/StringRef.h"
00015 
00016 namespace clang {
00017 
00018 namespace frontend {
00019 
00020 enum LangFeatures {
00021   LineComment = (1 << 0),
00022   C89 = (1 << 1),
00023   C99 = (1 << 2),
00024   C11 = (1 << 3),
00025   CPlusPlus = (1 << 4),
00026   CPlusPlus11 = (1 << 5),
00027   CPlusPlus14 = (1 << 6),
00028   CPlusPlus1z = (1 << 7),
00029   Digraphs = (1 << 8),
00030   GNUMode = (1 << 9),
00031   HexFloat = (1 << 10),
00032   ImplicitInt = (1 << 11)
00033 };
00034 
00035 }
00036 
00037 /// LangStandard - Information about the properties of a particular language
00038 /// standard.
00039 struct LangStandard {
00040   enum Kind {
00041 #define LANGSTANDARD(id, name, desc, features) \
00042     lang_##id,
00043 #include "clang/Frontend/LangStandards.def"
00044     lang_unspecified
00045   };
00046 
00047   const char *ShortName;
00048   const char *Description;
00049   unsigned Flags;
00050 
00051 public:
00052   /// getName - Get the name of this standard.
00053   const char *getName() const { return ShortName; }
00054 
00055   /// getDescription - Get the description of this standard.
00056   const char *getDescription() const { return Description; }
00057 
00058   /// Language supports '//' comments.
00059   bool hasLineComments() const { return Flags & frontend::LineComment; }
00060 
00061   /// isC89 - Language is a superset of C89.
00062   bool isC89() const { return Flags & frontend::C89; }
00063 
00064   /// isC99 - Language is a superset of C99.
00065   bool isC99() const { return Flags & frontend::C99; }
00066 
00067   /// isC11 - Language is a superset of C11.
00068   bool isC11() const { return Flags & frontend::C11; }
00069 
00070   /// isCPlusPlus - Language is a C++ variant.
00071   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
00072 
00073   /// isCPlusPlus11 - Language is a C++11 variant (or later).
00074   bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
00075 
00076   /// isCPlusPlus14 - Language is a C++14 variant (or later).
00077   bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; }
00078 
00079   /// isCPlusPlus1z - Language is a C++17 variant (or later).
00080   bool isCPlusPlus1z() const { return Flags & frontend::CPlusPlus1z; }
00081 
00082   /// hasDigraphs - Language supports digraphs.
00083   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
00084 
00085   /// isGNUMode - Language includes GNU extensions.
00086   bool isGNUMode() const { return Flags & frontend::GNUMode; }
00087 
00088   /// hasHexFloats - Language supports hexadecimal float constants.
00089   bool hasHexFloats() const { return Flags & frontend::HexFloat; }
00090 
00091   /// hasImplicitInt - Language allows variables to be typed as int implicitly.
00092   bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
00093 
00094   static const LangStandard &getLangStandardForKind(Kind K);
00095   static const LangStandard *getLangStandardForName(StringRef Name);
00096 };
00097 
00098 }  // end namespace clang
00099 
00100 #endif