clang 18.0.0git
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
15namespace llvm {
16class Triple;
17}
18
19namespace clang {
20
21/// The language for the input, used to select and validate the language
22/// standard and possible actions.
23enum class Language : uint8_t {
24 Unknown,
25
26 /// Assembly: we accept this only so that we can preprocess it.
27 Asm,
28
29 /// LLVM IR: we accept this so that we can run the optimizer on it,
30 /// and compile it to assembly or object code.
31 LLVM_IR,
32
33 ///@{ Languages that the frontend can parse and compile.
34 C,
35 CXX,
36 ObjC,
37 ObjCXX,
38 OpenCL,
40 CUDA,
42 HIP,
43 HLSL,
44 ///@}
45};
46
48 LineComment = (1 << 0),
49 C99 = (1 << 1),
50 C11 = (1 << 2),
51 C17 = (1 << 3),
52 C23 = (1 << 4),
53 CPlusPlus = (1 << 5),
54 CPlusPlus11 = (1 << 6),
55 CPlusPlus14 = (1 << 7),
56 CPlusPlus17 = (1 << 8),
57 CPlusPlus20 = (1 << 9),
58 CPlusPlus23 = (1 << 10),
59 CPlusPlus26 = (1 << 11),
60 Digraphs = (1 << 12),
61 GNUMode = (1 << 13),
62 HexFloat = (1 << 14),
63 OpenCL = (1 << 15),
64 HLSL = (1 << 16)
65};
66
67/// LangStandard - Information about the properties of a particular language
68/// standard.
70 enum Kind {
71#define LANGSTANDARD(id, name, lang, desc, features) \
72 lang_##id,
73#include "clang/Basic/LangStandards.def"
75 };
76
77 const char *ShortName;
78 const char *Description;
79 unsigned Flags;
81
82public:
83 /// getName - Get the name of this standard.
84 const char *getName() const { return ShortName; }
85
86 /// getDescription - Get the description of this standard.
87 const char *getDescription() const { return Description; }
88
89 /// Get the language that this standard describes.
91
92 /// Language supports '//' comments.
93 bool hasLineComments() const { return Flags & LineComment; }
94
95 /// isC99 - Language is a superset of C99.
96 bool isC99() const { return Flags & C99; }
97
98 /// isC11 - Language is a superset of C11.
99 bool isC11() const { return Flags & C11; }
100
101 /// isC17 - Language is a superset of C17.
102 bool isC17() const { return Flags & C17; }
103
104 /// isC23 - Language is a superset of C23.
105 bool isC23() const { return Flags & C23; }
106
107 /// isCPlusPlus - Language is a C++ variant.
108 bool isCPlusPlus() const { return Flags & CPlusPlus; }
109
110 /// isCPlusPlus11 - Language is a C++11 variant (or later).
111 bool isCPlusPlus11() const { return Flags & CPlusPlus11; }
112
113 /// isCPlusPlus14 - Language is a C++14 variant (or later).
114 bool isCPlusPlus14() const { return Flags & CPlusPlus14; }
115
116 /// isCPlusPlus17 - Language is a C++17 variant (or later).
117 bool isCPlusPlus17() const { return Flags & CPlusPlus17; }
118
119 /// isCPlusPlus20 - Language is a C++20 variant (or later).
120 bool isCPlusPlus20() const { return Flags & CPlusPlus20; }
121
122 /// isCPlusPlus23 - Language is a post-C++23 variant (or later).
123 bool isCPlusPlus23() const { return Flags & CPlusPlus23; }
124
125 /// isCPlusPlus26 - Language is a post-C++26 variant (or later).
126 bool isCPlusPlus26() const { return Flags & CPlusPlus26; }
127
128 /// hasDigraphs - Language supports digraphs.
129 bool hasDigraphs() const { return Flags & Digraphs; }
130
131 /// isGNUMode - Language includes GNU extensions.
132 bool isGNUMode() const { return Flags & GNUMode; }
133
134 /// hasHexFloats - Language supports hexadecimal float constants.
135 bool hasHexFloats() const { return Flags & HexFloat; }
136
137 /// isOpenCL - Language is a OpenCL variant.
138 bool isOpenCL() const { return Flags & OpenCL; }
139
140 static Kind getLangKind(StringRef Name);
142 static const LangStandard *getLangStandardForName(StringRef Name);
143};
144
146 const llvm::Triple &T);
147
148} // end namespace clang
149
150#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
LangFeatures
Definition: LangStandard.h:47
@ GNUMode
Definition: LangStandard.h:61
@ OpenCL
Definition: LangStandard.h:63
@ CPlusPlus23
Definition: LangStandard.h:58
@ CPlusPlus20
Definition: LangStandard.h:57
@ LineComment
Definition: LangStandard.h:48
@ CPlusPlus
Definition: LangStandard.h:53
@ CPlusPlus11
Definition: LangStandard.h:54
@ CPlusPlus14
Definition: LangStandard.h:55
@ HexFloat
Definition: LangStandard.h:62
@ CPlusPlus26
Definition: LangStandard.h:59
@ Digraphs
Definition: LangStandard.h:60
@ CPlusPlus17
Definition: LangStandard.h:56
LangStandard::Kind getDefaultLanguageStandard(clang::Language Lang, const llvm::Triple &T)
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
@ C
Languages that the frontend can parse and compile.
@ LLVM_IR
LLVM IR: we accept this so that we can run the optimizer on it, and compile it to assembly or object ...
@ Asm
Assembly: we accept this only so that we can preprocess it.
YAML serialization mapping.
Definition: Dominators.h:30
LangStandard - Information about the properties of a particular language standard.
Definition: LangStandard.h:69
bool isCPlusPlus20() const
isCPlusPlus20 - Language is a C++20 variant (or later).
Definition: LangStandard.h:120
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
Definition: LangStandard.h:108
const char * Description
Definition: LangStandard.h:78
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
Definition: LangStandard.h:135
bool isC11() const
isC11 - Language is a superset of C11.
Definition: LangStandard.h:99
static const LangStandard * getLangStandardForName(StringRef Name)
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
Definition: LangStandard.h:117
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
Definition: LangStandard.h:129
clang::Language getLanguage() const
Get the language that this standard describes.
Definition: LangStandard.h:90
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
Definition: LangStandard.h:114
const char * getDescription() const
getDescription - Get the description of this standard.
Definition: LangStandard.h:87
bool isC17() const
isC17 - Language is a superset of C17.
Definition: LangStandard.h:102
bool isCPlusPlus26() const
isCPlusPlus26 - Language is a post-C++26 variant (or later).
Definition: LangStandard.h:126
const char * ShortName
Definition: LangStandard.h:77
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
Definition: LangStandard.h:111
bool isC23() const
isC23 - Language is a superset of C23.
Definition: LangStandard.h:105
clang::Language Language
Definition: LangStandard.h:80
static const LangStandard & getLangStandardForKind(Kind K)
bool isOpenCL() const
isOpenCL - Language is a OpenCL variant.
Definition: LangStandard.h:138
const char * getName() const
getName - Get the name of this standard.
Definition: LangStandard.h:84
bool hasLineComments() const
Language supports '//' comments.
Definition: LangStandard.h:93
bool isCPlusPlus23() const
isCPlusPlus23 - Language is a post-C++23 variant (or later).
Definition: LangStandard.h:123
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
Definition: LangStandard.h:132
static Kind getLangKind(StringRef Name)
bool isC99() const
isC99 - Language is a superset of C99.
Definition: LangStandard.h:96