clang  6.0.0svn
LangStandard.h
Go to the documentation of this file.
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"
15 #include "llvm/ADT/StringRef.h"
16 
17 namespace clang {
18 
19 namespace frontend {
20 
22  LineComment = (1 << 0),
23  C99 = (1 << 1),
24  C11 = (1 << 2),
25  C17 = (1 << 3),
26  CPlusPlus = (1 << 4),
27  CPlusPlus11 = (1 << 5),
28  CPlusPlus14 = (1 << 6),
29  CPlusPlus17 = (1 << 7),
30  CPlusPlus2a = (1 << 8),
31  Digraphs = (1 << 9),
32  GNUMode = (1 << 10),
33  HexFloat = (1 << 11),
34  ImplicitInt = (1 << 12),
35  OpenCL = (1 << 13)
36 };
37 
38 }
39 
40 /// LangStandard - Information about the properties of a particular language
41 /// standard.
42 struct LangStandard {
43  enum Kind {
44 #define LANGSTANDARD(id, name, lang, desc, features) \
45  lang_##id,
46 #include "clang/Frontend/LangStandards.def"
47  lang_unspecified
48  };
49 
50  const char *ShortName;
51  const char *Description;
52  unsigned Flags;
54 
55 public:
56  /// getName - Get the name of this standard.
57  const char *getName() const { return ShortName; }
58 
59  /// getDescription - Get the description of this standard.
60  const char *getDescription() const { return Description; }
61 
62  /// Get the language that this standard describes.
63  InputKind::Language getLanguage() const { return Language; }
64 
65  /// Language supports '//' comments.
66  bool hasLineComments() const { return Flags & frontend::LineComment; }
67 
68  /// isC99 - Language is a superset of C99.
69  bool isC99() const { return Flags & frontend::C99; }
70 
71  /// isC11 - Language is a superset of C11.
72  bool isC11() const { return Flags & frontend::C11; }
73 
74  /// isC17 - Language is a superset of C17.
75  bool isC17() const { return Flags & frontend::C17; }
76 
77  /// isCPlusPlus - Language is a C++ variant.
78  bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
79 
80  /// isCPlusPlus11 - Language is a C++11 variant (or later).
81  bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
82 
83  /// isCPlusPlus14 - Language is a C++14 variant (or later).
84  bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; }
85 
86  /// isCPlusPlus17 - Language is a C++17 variant (or later).
87  bool isCPlusPlus17() const { return Flags & frontend::CPlusPlus17; }
88 
89  /// isCPlusPlus2a - Language is a post-C++17 variant (or later).
90  bool isCPlusPlus2a() const { return Flags & frontend::CPlusPlus2a; }
91 
92 
93  /// hasDigraphs - Language supports digraphs.
94  bool hasDigraphs() const { return Flags & frontend::Digraphs; }
95 
96  /// isGNUMode - Language includes GNU extensions.
97  bool isGNUMode() const { return Flags & frontend::GNUMode; }
98 
99  /// hasHexFloats - Language supports hexadecimal float constants.
100  bool hasHexFloats() const { return Flags & frontend::HexFloat; }
101 
102  /// hasImplicitInt - Language allows variables to be typed as int implicitly.
103  bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
104 
105  /// isOpenCL - Language is a OpenCL variant.
106  bool isOpenCL() const { return Flags & frontend::OpenCL; }
107 
108  static const LangStandard &getLangStandardForKind(Kind K);
109  static const LangStandard *getLangStandardForName(StringRef Name);
110 };
111 
112 } // end namespace clang
113 
114 #endif
LangStandard - Information about the properties of a particular language standard.
Definition: LangStandard.h:42
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
Definition: LangStandard.h:94
InputKind::Language getLanguage() const
Get the language that this standard describes.
Definition: LangStandard.h:63
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
Definition: LangStandard.h:84
bool hasLineComments() const
Language supports &#39;//&#39; comments.
Definition: LangStandard.h:66
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool isOpenCL() const
isOpenCL - Language is a OpenCL variant.
Definition: LangStandard.h:106
bool isCPlusPlus2a() const
isCPlusPlus2a - Language is a post-C++17 variant (or later).
Definition: LangStandard.h:90
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
Definition: LangStandard.h:78
const char * getName() const
getName - Get the name of this standard.
Definition: LangStandard.h:57
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
Definition: LangStandard.h:81
bool hasImplicitInt() const
hasImplicitInt - Language allows variables to be typed as int implicitly.
Definition: LangStandard.h:103
bool isC11() const
isC11 - Language is a superset of C11.
Definition: LangStandard.h:72
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
Definition: LangStandard.h:100
const char * ShortName
Definition: LangStandard.h:50
InputKind::Language Language
Definition: LangStandard.h:53
Dataflow Directional Tag Classes.
const char * Description
Definition: LangStandard.h:51
Language
The language for the input, used to select and validate the language standard and possible actions...
bool isC17() const
isC17 - Language is a superset of C17.
Definition: LangStandard.h:75
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
Definition: LangStandard.h:97
bool isC99() const
isC99 - Language is a superset of C99.
Definition: LangStandard.h:69
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
Definition: LangStandard.h:87
const char * getDescription() const
getDescription - Get the description of this standard.
Definition: LangStandard.h:60