clang  9.0.0svn
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_FRONTEND_LANGSTANDARD_H
10 #define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
11 
12 #include "clang/Basic/LLVM.h"
14 #include "llvm/ADT/StringRef.h"
15 
16 namespace clang {
17 
18 namespace frontend {
19 
21  LineComment = (1 << 0),
22  C99 = (1 << 1),
23  C11 = (1 << 2),
24  C17 = (1 << 3),
25  CPlusPlus = (1 << 4),
26  CPlusPlus11 = (1 << 5),
27  CPlusPlus14 = (1 << 6),
28  CPlusPlus17 = (1 << 7),
29  CPlusPlus2a = (1 << 8),
30  Digraphs = (1 << 9),
31  GNUMode = (1 << 10),
32  HexFloat = (1 << 11),
33  ImplicitInt = (1 << 12),
34  OpenCL = (1 << 13)
35 };
36 
37 }
38 
39 /// LangStandard - Information about the properties of a particular language
40 /// standard.
41 struct LangStandard {
42  enum Kind {
43 #define LANGSTANDARD(id, name, lang, desc, features) \
44  lang_##id,
45 #include "clang/Frontend/LangStandards.def"
46  lang_unspecified
47  };
48 
49  const char *ShortName;
50  const char *Description;
51  unsigned Flags;
53 
54 public:
55  /// getName - Get the name of this standard.
56  const char *getName() const { return ShortName; }
57 
58  /// getDescription - Get the description of this standard.
59  const char *getDescription() const { return Description; }
60 
61  /// Get the language that this standard describes.
62  InputKind::Language getLanguage() const { return Language; }
63 
64  /// Language supports '//' comments.
65  bool hasLineComments() const { return Flags & frontend::LineComment; }
66 
67  /// isC99 - Language is a superset of C99.
68  bool isC99() const { return Flags & frontend::C99; }
69 
70  /// isC11 - Language is a superset of C11.
71  bool isC11() const { return Flags & frontend::C11; }
72 
73  /// isC17 - Language is a superset of C17.
74  bool isC17() const { return Flags & frontend::C17; }
75 
76  /// isCPlusPlus - Language is a C++ variant.
77  bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
78 
79  /// isCPlusPlus11 - Language is a C++11 variant (or later).
80  bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
81 
82  /// isCPlusPlus14 - Language is a C++14 variant (or later).
83  bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; }
84 
85  /// isCPlusPlus17 - Language is a C++17 variant (or later).
86  bool isCPlusPlus17() const { return Flags & frontend::CPlusPlus17; }
87 
88  /// isCPlusPlus2a - Language is a post-C++17 variant (or later).
89  bool isCPlusPlus2a() const { return Flags & frontend::CPlusPlus2a; }
90 
91 
92  /// hasDigraphs - Language supports digraphs.
93  bool hasDigraphs() const { return Flags & frontend::Digraphs; }
94 
95  /// isGNUMode - Language includes GNU extensions.
96  bool isGNUMode() const { return Flags & frontend::GNUMode; }
97 
98  /// hasHexFloats - Language supports hexadecimal float constants.
99  bool hasHexFloats() const { return Flags & frontend::HexFloat; }
100 
101  /// hasImplicitInt - Language allows variables to be typed as int implicitly.
102  bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
103 
104  /// isOpenCL - Language is a OpenCL variant.
105  bool isOpenCL() const { return Flags & frontend::OpenCL; }
106 
107  static const LangStandard &getLangStandardForKind(Kind K);
108  static const LangStandard *getLangStandardForName(StringRef Name);
109 };
110 
111 } // end namespace clang
112 
113 #endif
LangStandard - Information about the properties of a particular language standard.
Definition: LangStandard.h:41
bool hasDigraphs() const
hasDigraphs - Language supports digraphs.
Definition: LangStandard.h:93
InputKind::Language getLanguage() const
Get the language that this standard describes.
Definition: LangStandard.h:62
bool isCPlusPlus14() const
isCPlusPlus14 - Language is a C++14 variant (or later).
Definition: LangStandard.h:83
bool hasLineComments() const
Language supports &#39;//&#39; comments.
Definition: LangStandard.h:65
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
bool isOpenCL() const
isOpenCL - Language is a OpenCL variant.
Definition: LangStandard.h:105
bool isCPlusPlus2a() const
isCPlusPlus2a - Language is a post-C++17 variant (or later).
Definition: LangStandard.h:89
bool isCPlusPlus() const
isCPlusPlus - Language is a C++ variant.
Definition: LangStandard.h:77
const char * getName() const
getName - Get the name of this standard.
Definition: LangStandard.h:56
bool isCPlusPlus11() const
isCPlusPlus11 - Language is a C++11 variant (or later).
Definition: LangStandard.h:80
bool hasImplicitInt() const
hasImplicitInt - Language allows variables to be typed as int implicitly.
Definition: LangStandard.h:102
bool isC11() const
isC11 - Language is a superset of C11.
Definition: LangStandard.h:71
bool hasHexFloats() const
hasHexFloats - Language supports hexadecimal float constants.
Definition: LangStandard.h:99
const char * ShortName
Definition: LangStandard.h:49
InputKind::Language Language
Definition: LangStandard.h:52
Dataflow Directional Tag Classes.
const char * Description
Definition: LangStandard.h:50
Language
The language for the input, used to select and validate the language standard and possible actions...
bool isC17() const
isC17 - Language is a superset of C17.
Definition: LangStandard.h:74
bool isGNUMode() const
isGNUMode - Language includes GNU extensions.
Definition: LangStandard.h:96
bool isC99() const
isC99 - Language is a superset of C99.
Definition: LangStandard.h:68
bool isCPlusPlus17() const
isCPlusPlus17 - Language is a C++17 variant (or later).
Definition: LangStandard.h:86
const char * getDescription() const
getDescription - Get the description of this standard.
Definition: LangStandard.h:59