Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/LangStandard.h
Line
Count
Source
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 llvm {
16
class Triple;
17
}
18
19
namespace clang {
20
21
/// The language for the input, used to select and validate the language
22
/// standard and possible actions.
23
enum 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,
39
  OpenCLCXX,
40
  CUDA,
41
  RenderScript,
42
  HIP,
43
  HLSL,
44
  ///@}
45
};
46
47
enum LangFeatures {
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.
68
struct LangStandard {
69
  enum Kind {
70
#define LANGSTANDARD(id, name, lang, desc, features) \
71
    lang_##id,
72
#include "clang/Basic/LangStandards.def"
73
    lang_unspecified
74
  };
75
76
  const char *ShortName;
77
  const char *Description;
78
  unsigned Flags;
79
  clang::Language Language;
80
81
public:
82
  /// getName - Get the name of this standard.
83
143k
  const char *getName() const { return ShortName; }
84
85
  /// getDescription - Get the description of this standard.
86
176
  const char *getDescription() const { return Description; }
87
88
  /// Get the language that this standard describes.
89
111k
  clang::Language getLanguage() const { return Language; }
90
91
  /// Language supports '//' comments.
92
151k
  bool hasLineComments() const { return Flags & LineComment; }
93
94
  /// isC99 - Language is a superset of C99.
95
159k
  bool isC99() const { return Flags & C99; }
96
97
  /// isC11 - Language is a superset of C11.
98
143k
  bool isC11() const { return Flags & C11; }
99
100
  /// isC17 - Language is a superset of C17.
101
143k
  bool isC17() const { return Flags & C17; }
102
103
  /// isC2x - Language is a superset of C2x.
104
143k
  bool isC2x() const { return Flags & C2x; }
105
106
  /// isCPlusPlus - Language is a C++ variant.
107
295k
  bool isCPlusPlus() const { return Flags & CPlusPlus; }
108
109
  /// isCPlusPlus11 - Language is a C++11 variant (or later).
110
151k
  bool isCPlusPlus11() const { return Flags & CPlusPlus11; }
111
112
  /// isCPlusPlus14 - Language is a C++14 variant (or later).
113
143k
  bool isCPlusPlus14() const { return Flags & CPlusPlus14; }
114
115
  /// isCPlusPlus17 - Language is a C++17 variant (or later).
116
143k
  bool isCPlusPlus17() const { return Flags & CPlusPlus17; }
117
118
  /// isCPlusPlus20 - Language is a C++20 variant (or later).
119
143k
  bool isCPlusPlus20() const { return Flags & CPlusPlus20; }
120
121
  /// isCPlusPlus2b - Language is a post-C++20 variant (or later).
122
143k
  bool isCPlusPlus2b() const { return Flags & CPlusPlus2b; }
123
124
  /// hasDigraphs - Language supports digraphs.
125
726k
  bool hasDigraphs() const { return Flags & Digraphs; }
126
127
  /// isGNUMode - Language includes GNU extensions.
128
151k
  bool isGNUMode() const { return Flags & GNUMode; }
129
130
  /// hasHexFloats - Language supports hexadecimal float constants.
131
151k
  bool hasHexFloats() const { return Flags & HexFloat; }
132
133
  /// isOpenCL - Language is a OpenCL variant.
134
143k
  bool isOpenCL() const { return Flags & OpenCL; }
135
136
  static Kind getLangKind(StringRef Name);
137
  static const LangStandard &getLangStandardForKind(Kind K);
138
  static const LangStandard *getLangStandardForName(StringRef Name);
139
};
140
141
LangStandard::Kind getDefaultLanguageStandard(clang::Language Lang,
142
                                              const llvm::Triple &T);
143
144
}  // end namespace clang
145
146
#endif