clang 17.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 C2x = (1 << 4),
53 CPlusPlus = (1 << 5),
54 CPlusPlus11 = (1 << 6),
55 CPlusPlus14 = (1 << 7),
56 CPlusPlus17 = (1 << 8),
57 CPlusPlus20 = (1 << 9),
58 CPlusPlus2b = (1 << 10),
59 Digraphs = (1 << 11),
60 GNUMode = (1 << 12),
61 HexFloat = (1 << 13),
62 OpenCL = (1 << 14),
63 HLSL = (1 << 15)
64};
65
66/// LangStandard - Information about the properties of a particular language
67/// standard.
69 enum Kind {
70#define LANGSTANDARD(id, name, lang, desc, features) \
71 lang_##id,
72#include "clang/Basic/LangStandards.def"
74 };
75
76 const char *ShortName;
77 const char *Description;
78 unsigned Flags;
80
81public:
82 /// getName - Get the name of this standard.
83 const char *getName() const { return ShortName; }
84
85 /// getDescription - Get the description of this standard.
86 const char *getDescription() const { return Description; }
87
88 /// Get the language that this standard describes.
90
91 /// Language supports '//' comments.
92 bool hasLineComments() const { return Flags & LineComment; }
93
94 /// isC99 - Language is a superset of C99.
95 bool isC99() const { return Flags & C99; }
96
97 /// isC11 - Language is a superset of C11.
98 bool isC11() const { return Flags & C11; }
99
100 /// isC17 - Language is a superset of C17.
101 bool isC17() const { return Flags & C17; }
102
103 /// isC2x - Language is a superset of C2x.
104 bool isC2x() const { return Flags & C2x; }
105
106 /// isCPlusPlus - Language is a C++ variant.
107 bool isCPlusPlus() const { return Flags & CPlusPlus; }
108
109 /// isCPlusPlus11 - Language is a C++11 variant (or later).
110 bool isCPlusPlus11() const { return Flags & CPlusPlus11; }
111
112 /// isCPlusPlus14 - Language is a C++14 variant (or later).
113 bool isCPlusPlus14() const { return Flags & CPlusPlus14; }
114
115 /// isCPlusPlus17 - Language is a C++17 variant (or later).
116 bool isCPlusPlus17() const { return Flags & CPlusPlus17; }
117
118 /// isCPlusPlus20 - Language is a C++20 variant (or later).
119 bool isCPlusPlus20() const { return Flags & CPlusPlus20; }
120
121 /// isCPlusPlus2b - Language is a post-C++20 variant (or later).
122 bool isCPlusPlus2b() const { return Flags & CPlusPlus2b; }
123
124 /// hasDigraphs - Language supports digraphs.
125 bool hasDigraphs() const { return Flags & Digraphs; }
126
127 /// isGNUMode - Language includes GNU extensions.
128 bool isGNUMode() const { return Flags & GNUMode; }
129
130 /// hasHexFloats - Language supports hexadecimal float constants.
131 bool hasHexFloats() const { return Flags & HexFloat; }
132
133 /// isOpenCL - Language is a OpenCL variant.
134 bool isOpenCL() const { return Flags & OpenCL; }
135
136 static Kind getLangKind(StringRef Name);
138 static const LangStandard *getLangStandardForName(StringRef Name);
139};
140
142 const llvm::Triple &T);
143
144} // end namespace clang
145
146#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
LangFeatures
Definition: LangStandard.h:47
@ GNUMode
Definition: LangStandard.h:60
@ OpenCL
Definition: LangStandard.h:62
@ CPlusPlus20
Definition: LangStandard.h:57
@ LineComment
Definition: LangStandard.h:48
@ CPlusPlus
Definition: LangStandard.h:53
@ CPlusPlus11
Definition: LangStandard.h:54
@ CPlusPlus2b
Definition: LangStandard.h:58
@ CPlusPlus14
Definition: LangStandard.h:55
@ HexFloat
Definition: LangStandard.h:61
@ Digraphs
Definition: LangStandard.h:59
@ 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:68
bool isCPlusPlus20() const
isCPlusPlus20 - Language is a C++20 variant (or later).
Definition: LangStandard.h:119
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
Definition: LangStandard.h:107
const char * Description
Definition: LangStandard.h:77
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
Definition: LangStandard.h:131
bool isC11() const
isC11 - Language is a superset of C11.
Definition: LangStandard.h:98
static const LangStandard * getLangStandardForName(StringRef Name)
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
Definition: LangStandard.h:116
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
Definition: LangStandard.h:125
bool isCPlusPlus2b() const
isCPlusPlus2b - Language is a post-C++20 variant (or later).
Definition: LangStandard.h:122
clang::Language getLanguage() const
Get the language that this standard describes.
Definition: LangStandard.h:89
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
Definition: LangStandard.h:113
const char * getDescription() const
getDescription - Get the description of this standard.
Definition: LangStandard.h:86
bool isC17() const
isC17 - Language is a superset of C17.
Definition: LangStandard.h:101
const char * ShortName
Definition: LangStandard.h:76
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
Definition: LangStandard.h:110
clang::Language Language
Definition: LangStandard.h:79
static const LangStandard & getLangStandardForKind(Kind K)
bool isOpenCL() const
isOpenCL - Language is a OpenCL variant.
Definition: LangStandard.h:134
const char * getName() const
getName - Get the name of this standard.
Definition: LangStandard.h:83
bool hasLineComments() const
Language supports '//' comments.
Definition: LangStandard.h:92
bool isC2x() const
isC2x - Language is a superset of C2x.
Definition: LangStandard.h:104
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
Definition: LangStandard.h:128
static Kind getLangKind(StringRef Name)
bool isC99() const
isC99 - Language is a superset of C99.
Definition: LangStandard.h:95