1 //===--- LangStandards.cpp - Language Standard Definitions ----------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "clang/Basic/LangStandard.h"
10 #include "llvm/ADT/StringSwitch.h"
11 #include "llvm/Support/ErrorHandling.h"
12 using namespace clang
;
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"
18 const LangStandard
&LangStandard::getLangStandardForKind(Kind 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"
26 llvm_unreachable("Invalid language kind!");
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
);
37 const LangStandard
*LangStandard::getLangStandardForName(StringRef Name
) {
38 Kind K
= getLangKind(Name
);
39 if (K
== lang_unspecified
)
42 return &getLangStandardForKind(K
);