clang  10.0.0svn
LangStandard.h
Go to the documentation of this file.
1 //===--- LangStandard.h -----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_BASIC_LANGSTANDARD_H
10 #define LLVM_CLANG_BASIC_LANGSTANDARD_H
11 
12 #include "clang/Basic/LLVM.h"
13 #include "llvm/ADT/StringRef.h"
14 
15 namespace clang {
16 
17 /// The language for the input, used to select and validate the language
18 /// standard and possible actions.
19 enum class Language : uint8_t {
20  Unknown,
21 
22  /// Assembly: we accept this only so that we can preprocess it.
23  Asm,
24 
25  /// LLVM IR: we accept this so that we can run the optimizer on it,
26  /// and compile it to assembly or object code.
27  LLVM_IR,
28 
29  ///@{ Languages that the frontend can parse and compile.
30  C,
31  CXX,
32  ObjC,
33  ObjCXX,
34  OpenCL,
35  CUDA,
37  HIP,
38  ///@}
39 };
40 
42  LineComment = (1 << 0),
43  C99 = (1 << 1),
44  C11 = (1 << 2),
45  C17 = (1 << 3),
46  C2x = (1 << 4),
47  CPlusPlus = (1 << 5),
48  CPlusPlus11 = (1 << 6),
49  CPlusPlus14 = (1 << 7),
50  CPlusPlus17 = (1 << 8),
51  CPlusPlus2a = (1 << 9),
52  Digraphs = (1 << 10),
53  GNUMode = (1 << 11),
54  HexFloat = (1 << 12),
55  ImplicitInt = (1 << 13),
56  OpenCL = (1 << 14)
57 };
58 
59 /// LangStandard - Information about the properties of a particular language
60 /// standard.
61 struct LangStandard {
62  enum Kind {
63 #define LANGSTANDARD(id, name, lang, desc, features) \
64  lang_##id,
65 #include "clang/Basic/LangStandards.def"
66  lang_unspecified
67  };
68 
69  const char *ShortName;
70  const char *Description;
71  unsigned Flags;
73 
74 public:
75  /// getName - Get the name of this standard.
76  const char *getName() const { return ShortName; }
77 
78  /// getDescription - Get the description of this standard.
79  const char *getDescription() const { return Description; }
80 
81  /// Get the language that this standard describes.
82  clang::Language getLanguage() const { return Language; }
83 
84  /// Language supports '//' comments.
85  bool hasLineComments() const { return Flags & LineComment; }
86 
87  /// isC99 - Language is a superset of C99.
88  bool isC99() const { return Flags & C99; }
89 
90  /// isC11 - Language is a superset of C11.
91  bool isC11() const { return Flags & C11; }
92 
93  /// isC17 - Language is a superset of C17.
94  bool isC17() const { return Flags & C17; }
95 
96  /// isC2x - Language is a superset of C2x.
97  bool isC2x() const { return Flags & C2x; }
98 
99  /// isCPlusPlus - Language is a C++ variant.
100  bool isCPlusPlus() const { return Flags & CPlusPlus; }
101 
102  /// isCPlusPlus11 - Language is a C++11 variant (or later).
103  bool isCPlusPlus11() const { return Flags & CPlusPlus11; }
104 
105  /// isCPlusPlus14 - Language is a C++14 variant (or later).
106  bool isCPlusPlus14() const { return Flags & CPlusPlus14; }
107 
108  /// isCPlusPlus17 - Language is a C++17 variant (or later).
109  bool isCPlusPlus17() const { return Flags & CPlusPlus17; }
110 
111  /// isCPlusPlus2a - Language is a post-C++17 variant (or later).
112  bool isCPlusPlus2a() const { return Flags & CPlusPlus2a; }
113 
114  /// hasDigraphs - Language supports digraphs.
115  bool hasDigraphs() const { return Flags & Digraphs; }
116 
117  /// isGNUMode - Language includes GNU extensions.
118  bool isGNUMode() const { return Flags & GNUMode; }
119 
120  /// hasHexFloats - Language supports hexadecimal float constants.
121  bool hasHexFloats() const { return Flags & HexFloat; }
122 
123  /// hasImplicitInt - Language allows variables to be typed as int implicitly.
124  bool hasImplicitInt() const { return Flags & ImplicitInt; }
125 
126  /// isOpenCL - Language is a OpenCL variant.
127  bool isOpenCL() const { return Flags & OpenCL; }
128 
129  static Kind getLangKind(StringRef Name);
130  static const LangStandard &getLangStandardForKind(Kind K);
131  static const LangStandard *getLangStandardForName(StringRef Name);
132 };
133 
134 } // end namespace clang
135 
136 #endif
LangFeatures
Definition: LangStandard.h:41
LangStandard - Information about the properties of a particular language standard.
Definition: LangStandard.h:61
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
Definition: LangStandard.h:115
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
Definition: LangStandard.h:106
bool hasLineComments() const
Language supports &#39;//&#39; comments.
Definition: LangStandard.h:85
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:127
bool isCPlusPlus2a() const
isCPlusPlus2a - Language is a post-C++17 variant (or later).
Definition: LangStandard.h:112
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
Definition: LangStandard.h:100
Languages that the frontend can parse and compile.
Language
The language for the input, used to select and validate the language standard and possible actions...
Definition: LangStandard.h:19
const char * getName() const
getName - Get the name of this standard.
Definition: LangStandard.h:76
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
Definition: LangStandard.h:103
clang::Language getLanguage() const
Get the language that this standard describes.
Definition: LangStandard.h:82
bool hasImplicitInt() const
hasImplicitInt - Language allows variables to be typed as int implicitly.
Definition: LangStandard.h:124
bool isC2x() const
isC2x - Language is a superset of C2x.
Definition: LangStandard.h:97
bool isC11() const
isC11 - Language is a superset of C11.
Definition: LangStandard.h:91
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
Definition: LangStandard.h:121
const char * ShortName
Definition: LangStandard.h:69
Dataflow Directional Tag Classes.
clang::Language Language
Definition: LangStandard.h:72
const char * Description
Definition: LangStandard.h:70
bool isC17() const
isC17 - Language is a superset of C17.
Definition: LangStandard.h:94
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
Definition: LangStandard.h:118
Assembly: we accept this only so that we can preprocess it.
bool isC99() const
isC99 - Language is a superset of C99.
Definition: LangStandard.h:88
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
Definition: LangStandard.h:109
const char * getDescription() const
getDescription - Get the description of this standard.
Definition: LangStandard.h:79
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...