150
|
1 //===--- LangStandards.cpp - Language Standard Definitions ----------------===//
|
|
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 #include "clang/Basic/LangStandard.h"
|
|
10 #include "llvm/ADT/StringSwitch.h"
|
|
11 #include "llvm/Support/ErrorHandling.h"
|
|
12 using namespace clang;
|
|
13
|
|
14 #define LANGSTANDARD(id, name, lang, desc, features) \
|
|
15 static const LangStandard Lang_##id = {name, desc, features, Language::lang};
|
|
16 #include "clang/Basic/LangStandards.def"
|
|
17
|
|
18 const LangStandard &LangStandard::getLangStandardForKind(Kind K) {
|
|
19 switch (K) {
|
|
20 case lang_unspecified:
|
|
21 llvm::report_fatal_error("getLangStandardForKind() on unspecified kind");
|
|
22 #define LANGSTANDARD(id, name, lang, desc, features) \
|
|
23 case lang_##id: return Lang_##id;
|
|
24 #include "clang/Basic/LangStandards.def"
|
|
25 }
|
|
26 llvm_unreachable("Invalid language kind!");
|
|
27 }
|
|
28
|
|
29 LangStandard::Kind LangStandard::getLangKind(StringRef Name) {
|
|
30 return llvm::StringSwitch<Kind>(Name)
|
|
31 #define LANGSTANDARD(id, name, lang, desc, features) .Case(name, lang_##id)
|
|
32 #define LANGSTANDARD_ALIAS(id, alias) .Case(alias, lang_##id)
|
|
33 #include "clang/Basic/LangStandards.def"
|
|
34 .Default(lang_unspecified);
|
|
35 }
|
|
36
|
|
37 const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
|
|
38 Kind K = getLangKind(Name);
|
|
39 if (K == lang_unspecified)
|
|
40 return nullptr;
|
|
41
|
|
42 return &getLangStandardForKind(K);
|
|
43 }
|
|
44
|
|
45
|