]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/LangStandard.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r305575, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Frontend / LangStandard.h
1 //===--- LangStandard.h -----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_FRONTEND_LANGSTANDARD_H
11 #define LLVM_CLANG_FRONTEND_LANGSTANDARD_H
12
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Frontend/FrontendOptions.h"
15 #include "llvm/ADT/StringRef.h"
16
17 namespace clang {
18
19 namespace frontend {
20
21 enum LangFeatures {
22   LineComment = (1 << 0),
23   C99 = (1 << 1),
24   C11 = (1 << 2),
25   CPlusPlus = (1 << 3),
26   CPlusPlus11 = (1 << 4),
27   CPlusPlus14 = (1 << 5),
28   CPlusPlus1z = (1 << 6),
29   Digraphs = (1 << 7),
30   GNUMode = (1 << 8),
31   HexFloat = (1 << 9),
32   ImplicitInt = (1 << 10),
33   OpenCL = (1 << 11)
34 };
35
36 }
37
38 /// LangStandard - Information about the properties of a particular language
39 /// standard.
40 struct LangStandard {
41   enum Kind {
42 #define LANGSTANDARD(id, name, lang, desc, features) \
43     lang_##id,
44 #include "clang/Frontend/LangStandards.def"
45     lang_unspecified
46   };
47
48   const char *ShortName;
49   const char *Description;
50   unsigned Flags;
51   InputKind::Language Language;
52
53 public:
54   /// getName - Get the name of this standard.
55   const char *getName() const { return ShortName; }
56
57   /// getDescription - Get the description of this standard.
58   const char *getDescription() const { return Description; }
59
60   /// Get the language that this standard describes.
61   InputKind::Language getLanguage() const { return Language; }
62
63   /// Language supports '//' comments.
64   bool hasLineComments() const { return Flags & frontend::LineComment; }
65
66   /// isC99 - Language is a superset of C99.
67   bool isC99() const { return Flags & frontend::C99; }
68
69   /// isC11 - Language is a superset of C11.
70   bool isC11() const { return Flags & frontend::C11; }
71
72   /// isCPlusPlus - Language is a C++ variant.
73   bool isCPlusPlus() const { return Flags & frontend::CPlusPlus; }
74
75   /// isCPlusPlus11 - Language is a C++11 variant (or later).
76   bool isCPlusPlus11() const { return Flags & frontend::CPlusPlus11; }
77
78   /// isCPlusPlus14 - Language is a C++14 variant (or later).
79   bool isCPlusPlus14() const { return Flags & frontend::CPlusPlus14; }
80
81   /// isCPlusPlus1z - Language is a C++17 variant (or later).
82   bool isCPlusPlus1z() const { return Flags & frontend::CPlusPlus1z; }
83
84   /// hasDigraphs - Language supports digraphs.
85   bool hasDigraphs() const { return Flags & frontend::Digraphs; }
86
87   /// isGNUMode - Language includes GNU extensions.
88   bool isGNUMode() const { return Flags & frontend::GNUMode; }
89
90   /// hasHexFloats - Language supports hexadecimal float constants.
91   bool hasHexFloats() const { return Flags & frontend::HexFloat; }
92
93   /// hasImplicitInt - Language allows variables to be typed as int implicitly.
94   bool hasImplicitInt() const { return Flags & frontend::ImplicitInt; }
95
96   /// isOpenCL - Language is a OpenCL variant.
97   bool isOpenCL() const { return Flags & frontend::OpenCL; }
98
99   static const LangStandard &getLangStandardForKind(Kind K);
100   static const LangStandard *getLangStandardForName(StringRef Name);
101 };
102
103 }  // end namespace clang
104
105 #endif