• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 namespace clang {
16 
17 namespace frontend {
18 
19 enum LangFeatures {
20   BCPLComment = (1 << 0),
21   C89 = (1 << 1),
22   C99 = (1 << 2),
23   C1X = (1 << 3),
24   CPlusPlus = (1 << 4),
25   CPlusPlus0x = (1 << 5),
26   Digraphs = (1 << 6),
27   GNUMode = (1 << 7),
28   HexFloat = (1 << 8),
29   ImplicitInt = (1 << 9)
30 };
31 
32 }
33 
34 /// LangStandard - Information about the properties of a particular language
35 /// standard.
36 struct LangStandard {
37   enum Kind {
38 #define LANGSTANDARD(id, name, desc, features) \
39     lang_##id,
40 #include "clang/Frontend/LangStandards.def"
41     lang_unspecified
42   };
43 
44   const char *ShortName;
45   const char *Description;
46   unsigned Flags;
47 
48 public:
49   /// getName - Get the name of this standard.
getNameLangStandard50   const char *getName() const { return ShortName; }
51 
52   /// getDescription - Get the description of this standard.
getDescriptionLangStandard53   const char *getDescription() const { return Description; }
54 
55   /// hasBCPLComments - Language supports '//' comments.
hasBCPLCommentsLangStandard56   bool hasBCPLComments() const { return Flags & frontend::BCPLComment; }
57 
58   /// isC89 - Language is a superset of C89.
isC89LangStandard59   bool isC89() const { return Flags & frontend::C89; }
60 
61   /// isC99 - Language is a superset of C99.
isC99LangStandard62   bool isC99() const { return Flags & frontend::C99; }
63 
64   /// isC1X - Language is a superset of C1X.
isC1XLangStandard65   bool isC1X() const { return Flags & frontend::C1X; }
66 
67   /// isCPlusPlus - Language is a C++ variant.
isCPlusPlusLangStandard68   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
69 
70   /// isCPlusPlus0x - Language is a C++0x variant.
isCPlusPlus0xLangStandard71   bool isCPlusPlus0x() const { return Flags & frontend::CPlusPlus0x; }
72 
73   /// hasDigraphs - Language supports digraphs.
hasDigraphsLangStandard74   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
75 
76   /// isGNUMode - Language includes GNU extensions.
isGNUModeLangStandard77   bool isGNUMode() const { return Flags & frontend::GNUMode; }
78 
79   /// hasHexFloats - Language supports hexadecimal float constants.
hasHexFloatsLangStandard80   bool hasHexFloats() const { return Flags & frontend::HexFloat; }
81 
82   /// hasImplicitInt - Language allows variables to be typed as int implicitly.
hasImplicitIntLangStandard83   bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
84 
85   static const LangStandard &getLangStandardForKind(Kind K);
86   static const LangStandard *getLangStandardForName(llvm::StringRef Name);
87 };
88 
89 }  // end namespace clang
90 
91 #endif
92