[clang][extract-api][NFC] Use dedicated API to check for macro equality
[llvm-project.git] / clang / lib / Basic / LangStandards.cpp
blobee27bfd12113c561c8a36958cec8f55d99d8f95e
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 //===----------------------------------------------------------------------===//
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) {
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"
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)
40 return nullptr;
42 return &getLangStandardForKind(K);