Coverage Report

Created: 2020-02-18 08:44

/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 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,
36
  RenderScript,
37
  HIP,
38
  ///@}
39
};
40
41
enum LangFeatures {
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;
72
  clang::Language Language;
73
74
public:
75
  /// getName - Get the name of this standard.
76
85
  const char *getName() const { return ShortName; }
77
78
  /// getDescription - Get the description of this standard.
79
80
  const char *getDescription() const { return Description; }
80
81
  /// Get the language that this standard describes.
82
21.0k
  clang::Language getLanguage() const { return Language; }
83
84
  /// Language supports '//' comments.
85
51.3k
  bool hasLineComments() const { return Flags & LineComment; }
86
87
  /// isC99 - Language is a superset of C99.
88
58.0k
  bool isC99() const { return Flags & C99; }
89
90
  /// isC11 - Language is a superset of C11.
91
44.5k
  bool isC11() const { return Flags & C11; }
92
93
  /// isC17 - Language is a superset of C17.
94
44.5k
  bool isC17() const { return Flags & C17; }
95
96
  /// isC2x - Language is a superset of C2x.
97
44.5k
  bool isC2x() const { return Flags & C2x; }
98
99
  /// isCPlusPlus - Language is a C++ variant.
100
51.3k
  bool isCPlusPlus() const { return Flags & CPlusPlus; }
101
102
  /// isCPlusPlus11 - Language is a C++11 variant (or later).
103
51.3k
  bool isCPlusPlus11() const { return Flags & CPlusPlus11; }
104
105
  /// isCPlusPlus14 - Language is a C++14 variant (or later).
106
44.5k
  bool isCPlusPlus14() const { return Flags & CPlusPlus14; }
107
108
  /// isCPlusPlus17 - Language is a C++17 variant (or later).
109
44.5k
  bool isCPlusPlus17() const { return Flags & CPlusPlus17; }
110
111
  /// isCPlusPlus2a - Language is a post-C++17 variant (or later).
112
44.5k
  bool isCPlusPlus2a() const { return Flags & CPlusPlus2a; }
113
114
  /// hasDigraphs - Language supports digraphs.
115
51.3k
  bool hasDigraphs() const { return Flags & Digraphs; }
116
117
  /// isGNUMode - Language includes GNU extensions.
118
51.3k
  bool isGNUMode() const { return Flags & GNUMode; }
119
120
  /// hasHexFloats - Language supports hexadecimal float constants.
121
51.3k
  bool hasHexFloats() const { return Flags & HexFloat; }
122
123
  /// hasImplicitInt - Language allows variables to be typed as int implicitly.
124
51.3k
  bool hasImplicitInt() const { return Flags & ImplicitInt; }
125
126
  /// isOpenCL - Language is a OpenCL variant.
127
44.5k
  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