• 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 "clang/Basic/LLVM.h"
14 #include "llvm/ADT/StringRef.h"
15 
16 namespace clang {
17 
18 namespace frontend {
19 
20 enum LangFeatures {
21   LineComment = (1 << 0),
22   C89 = (1 << 1),
23   C99 = (1 << 2),
24   C11 = (1 << 3),
25   CPlusPlus = (1 << 4),
26   CPlusPlus11 = (1 << 5),
27   CPlusPlus1y = (1 << 6),
28   Digraphs = (1 << 7),
29   GNUMode = (1 << 8),
30   HexFloat = (1 << 9),
31   ImplicitInt = (1 << 10)
32 };
33 
34 }
35 
36 /// LangStandard - Information about the properties of a particular language
37 /// standard.
38 struct LangStandard {
39   enum Kind {
40 #define LANGSTANDARD(id, name, desc, features) \
41     lang_##id,
42 #include "clang/Frontend/LangStandards.def"
43     lang_unspecified
44   };
45 
46   const char *ShortName;
47   const char *Description;
48   unsigned Flags;
49 
50 public:
51   /// getName - Get the name of this standard.
getNameLangStandard52   const char *getName() const { return ShortName; }
53 
54   /// getDescription - Get the description of this standard.
getDescriptionLangStandard55   const char *getDescription() const { return Description; }
56 
57   /// Language supports '//' comments.
hasLineCommentsLangStandard58   bool hasLineComments() const { return Flags & frontend::LineComment; }
59 
60   /// isC89 - Language is a superset of C89.
isC89LangStandard61   bool isC89() const { return Flags & frontend::C89; }
62 
63   /// isC99 - Language is a superset of C99.
isC99LangStandard64   bool isC99() const { return Flags & frontend::C99; }
65 
66   /// isC11 - Language is a superset of C11.
isC11LangStandard67   bool isC11() const { return Flags & frontend::C11; }
68 
69   /// isCPlusPlus - Language is a C++ variant.
isCPlusPlusLangStandard70   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
71 
72   /// isCPlusPlus11 - Language is a C++0x variant.
isCPlusPlus11LangStandard73   bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
74 
75   /// isCPlusPlus1y - Language is a C++1y variant.
isCPlusPlus1yLangStandard76   bool isCPlusPlus1y() const { return Flags & frontend::CPlusPlus1y; }
77 
78   /// hasDigraphs - Language supports digraphs.
hasDigraphsLangStandard79   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
80 
81   /// isGNUMode - Language includes GNU extensions.
isGNUModeLangStandard82   bool isGNUMode() const { return Flags & frontend::GNUMode; }
83 
84   /// hasHexFloats - Language supports hexadecimal float constants.
hasHexFloatsLangStandard85   bool hasHexFloats() const { return Flags & frontend::HexFloat; }
86 
87   /// hasImplicitInt - Language allows variables to be typed as int implicitly.
hasImplicitIntLangStandard88   bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
89 
90   static const LangStandard &getLangStandardForKind(Kind K);
91   static const LangStandard *getLangStandardForName(StringRef Name);
92 };
93 
94 }  // end namespace clang
95 
96 #endif
97