LangStandard.h revision 221345
1//===--- LangStandard.h -----------------------------------------*- 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#ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H 11#define LLVM_CLANG_FRONTEND_LANGSTANDARD_H 12 13#include "llvm/ADT/StringRef.h" 14 15namespace clang { 16 17namespace frontend { 18 19enum LangFeatures { 20 BCPLComment = (1 << 0), 21 C99 = (1 << 1), 22 C1X = (1 << 2), 23 CPlusPlus = (1 << 3), 24 CPlusPlus0x = (1 << 4), 25 Digraphs = (1 << 5), 26 GNUMode = (1 << 6), 27 HexFloat = (1 << 7), 28 ImplicitInt = (1 << 8) 29}; 30 31} 32 33/// LangStandard - Information about the properties of a particular language 34/// standard. 35struct LangStandard { 36 enum Kind { 37#define LANGSTANDARD(id, name, desc, features) \ 38 lang_##id, 39#include "clang/Frontend/LangStandards.def" 40 lang_unspecified 41 }; 42 43 const char *ShortName; 44 const char *Description; 45 unsigned Flags; 46 47public: 48 /// getName - Get the name of this standard. 49 const char *getName() const { return ShortName; } 50 51 /// getDescription - Get the description of this standard. 52 const char *getDescription() const { return Description; } 53 54 /// hasBCPLComments - Language supports '//' comments. 55 bool hasBCPLComments() const { return Flags & frontend::BCPLComment; } 56 57 /// isC99 - Language is a superset of C99. 58 bool isC99() const { return Flags & frontend::C99; } 59 60 /// isC1X - Language is a superset of C1X. 61 bool isC1X() const { return Flags & frontend::C1X; } 62 63 /// isCPlusPlus - Language is a C++ variant. 64 bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; } 65 66 /// isCPlusPlus0x - Language is a C++0x variant. 67 bool isCPlusPlus0x() const { return Flags & frontend::CPlusPlus0x; } 68 69 /// hasDigraphs - Language supports digraphs. 70 bool hasDigraphs() const { return Flags & frontend::Digraphs; } 71 72 /// isGNUMode - Language includes GNU extensions. 73 bool isGNUMode() const { return Flags & frontend::GNUMode; } 74 75 /// hasHexFloats - Language supports hexadecimal float constants. 76 bool hasHexFloats() const { return Flags & frontend::HexFloat; } 77 78 /// hasImplicitInt - Language allows variables to be typed as int implicitly. 79 bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; } 80 81 static const LangStandard &getLangStandardForKind(Kind K); 82 static const LangStandard *getLangStandardForName(llvm::StringRef Name); 83}; 84 85} // end namespace clang 86 87#endif 88