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