• 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   BCPLComment = (1 << 0),
22   C89 = (1 << 1),
23   C99 = (1 << 2),
24   C11 = (1 << 3),
25   CPlusPlus = (1 << 4),
26   CPlusPlus0x = (1 << 5),
27   Digraphs = (1 << 6),
28   GNUMode = (1 << 7),
29   HexFloat = (1 << 8),
30   ImplicitInt = (1 << 9)
31 };
32 
33 }
34 
35 /// LangStandard - Information about the properties of a particular language
36 /// standard.
37 struct LangStandard {
38   enum Kind {
39 #define LANGSTANDARD(id, name, desc, features) \
40     lang_##id,
41 #include "clang/Frontend/LangStandards.def"
42     lang_unspecified
43   };
44 
45   const char *ShortName;
46   const char *Description;
47   unsigned Flags;
48 
49 public:
50   /// getName - Get the name of this standard.
getNameLangStandard51   const char *getName() const { return ShortName; }
52 
53   /// getDescription - Get the description of this standard.
getDescriptionLangStandard54   const char *getDescription() const { return Description; }
55 
56   /// hasBCPLComments - Language supports '//' comments.
hasBCPLCommentsLangStandard57   bool hasBCPLComments() const { return Flags & frontend::BCPLComment; }
58 
59   /// isC89 - Language is a superset of C89.
isC89LangStandard60   bool isC89() const { return Flags & frontend::C89; }
61 
62   /// isC99 - Language is a superset of C99.
isC99LangStandard63   bool isC99() const { return Flags & frontend::C99; }
64 
65   /// isC11 - Language is a superset of C11.
isC11LangStandard66   bool isC11() const { return Flags & frontend::C11; }
67 
68   /// isCPlusPlus - Language is a C++ variant.
isCPlusPlusLangStandard69   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
70 
71   /// isCPlusPlus0x - Language is a C++0x variant.
isCPlusPlus0xLangStandard72   bool isCPlusPlus0x() const { return Flags & frontend::CPlusPlus0x; }
73 
74   /// hasDigraphs - Language supports digraphs.
hasDigraphsLangStandard75   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
76 
77   /// isGNUMode - Language includes GNU extensions.
isGNUModeLangStandard78   bool isGNUMode() const { return Flags & frontend::GNUMode; }
79 
80   /// hasHexFloats - Language supports hexadecimal float constants.
hasHexFloatsLangStandard81   bool hasHexFloats() const { return Flags & frontend::HexFloat; }
82 
83   /// hasImplicitInt - Language allows variables to be typed as int implicitly.
hasImplicitIntLangStandard84   bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
85 
86   static const LangStandard &getLangStandardForKind(Kind K);
87   static const LangStandard *getLangStandardForName(StringRef Name);
88 };
89 
90 }  // end namespace clang
91 
92 #endif
93