clang API Documentation
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 BCPLComment = (1 << 0), 00022 C89 = (1 << 1), 00023 C99 = (1 << 2), 00024 C11 = (1 << 3), 00025 CPlusPlus = (1 << 4), 00026 CPlusPlus0x = (1 << 5), 00027 Digraphs = (1 << 6), 00028 GNUMode = (1 << 7), 00029 HexFloat = (1 << 8), 00030 ImplicitInt = (1 << 9) 00031 }; 00032 00033 } 00034 00035 /// LangStandard - Information about the properties of a particular language 00036 /// standard. 00037 struct LangStandard { 00038 enum Kind { 00039 #define LANGSTANDARD(id, name, desc, features) \ 00040 lang_##id, 00041 #include "clang/Frontend/LangStandards.def" 00042 lang_unspecified 00043 }; 00044 00045 const char *ShortName; 00046 const char *Description; 00047 unsigned Flags; 00048 00049 public: 00050 /// getName - Get the name of this standard. 00051 const char *getName() const { return ShortName; } 00052 00053 /// getDescription - Get the description of this standard. 00054 const char *getDescription() const { return Description; } 00055 00056 /// hasBCPLComments - Language supports '//' comments. 00057 bool hasBCPLComments() const { return Flags & frontend::BCPLComment; } 00058 00059 /// isC89 - Language is a superset of C89. 00060 bool isC89() const { return Flags & frontend::C89; } 00061 00062 /// isC99 - Language is a superset of C99. 00063 bool isC99() const { return Flags & frontend::C99; } 00064 00065 /// isC11 - Language is a superset of C11. 00066 bool isC11() const { return Flags & frontend::C11; } 00067 00068 /// isCPlusPlus - Language is a C++ variant. 00069 bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } 00070 00071 /// isCPlusPlus0x - Language is a C++0x variant. 00072 bool isCPlusPlus0x() const { return Flags & frontend::CPlusPlus0x; } 00073 00074 /// hasDigraphs - Language supports digraphs. 00075 bool hasDigraphs() const { return Flags & frontend::Digraphs; } 00076 00077 /// isGNUMode - Language includes GNU extensions. 00078 bool isGNUMode() const { return Flags & frontend::GNUMode; } 00079 00080 /// hasHexFloats - Language supports hexadecimal float constants. 00081 bool hasHexFloats() const { return Flags & frontend::HexFloat; } 00082 00083 /// hasImplicitInt - Language allows variables to be typed as int implicitly. 00084 bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; } 00085 00086 static const LangStandard &getLangStandardForKind(Kind K); 00087 static const LangStandard *getLangStandardForName(StringRef Name); 00088 }; 00089 00090 } // end namespace clang 00091 00092 #endif