xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Basic/LangStandards.cpp (revision 7330f729ccf0bd976a06f95fad452fe774fc7fd1)
1*7330f729Sjoerg //===--- LangStandards.cpp - Language Standard Definitions ----------------===//
2*7330f729Sjoerg //
3*7330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg //
7*7330f729Sjoerg //===----------------------------------------------------------------------===//
8*7330f729Sjoerg 
9*7330f729Sjoerg #include "clang/Basic/LangStandard.h"
10*7330f729Sjoerg #include "llvm/ADT/StringSwitch.h"
11*7330f729Sjoerg #include "llvm/Support/ErrorHandling.h"
12*7330f729Sjoerg using namespace clang;
13*7330f729Sjoerg 
14*7330f729Sjoerg #define LANGSTANDARD(id, name, lang, desc, features)                           \
15*7330f729Sjoerg   static const LangStandard Lang_##id = {name, desc, features, Language::lang};
16*7330f729Sjoerg #include "clang/Basic/LangStandards.def"
17*7330f729Sjoerg 
getLangStandardForKind(Kind K)18*7330f729Sjoerg const LangStandard &LangStandard::getLangStandardForKind(Kind K) {
19*7330f729Sjoerg   switch (K) {
20*7330f729Sjoerg   case lang_unspecified:
21*7330f729Sjoerg     llvm::report_fatal_error("getLangStandardForKind() on unspecified kind");
22*7330f729Sjoerg #define LANGSTANDARD(id, name, lang, desc, features) \
23*7330f729Sjoerg     case lang_##id: return Lang_##id;
24*7330f729Sjoerg #include "clang/Basic/LangStandards.def"
25*7330f729Sjoerg   }
26*7330f729Sjoerg   llvm_unreachable("Invalid language kind!");
27*7330f729Sjoerg }
28*7330f729Sjoerg 
getLangKind(StringRef Name)29*7330f729Sjoerg LangStandard::Kind LangStandard::getLangKind(StringRef Name) {
30*7330f729Sjoerg   return llvm::StringSwitch<Kind>(Name)
31*7330f729Sjoerg #define LANGSTANDARD(id, name, lang, desc, features) .Case(name, lang_##id)
32*7330f729Sjoerg #define LANGSTANDARD_ALIAS(id, alias) .Case(alias, lang_##id)
33*7330f729Sjoerg #include "clang/Basic/LangStandards.def"
34*7330f729Sjoerg       .Default(lang_unspecified);
35*7330f729Sjoerg }
36*7330f729Sjoerg 
getLangStandardForName(StringRef Name)37*7330f729Sjoerg const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
38*7330f729Sjoerg   Kind K = getLangKind(Name);
39*7330f729Sjoerg   if (K == lang_unspecified)
40*7330f729Sjoerg     return nullptr;
41*7330f729Sjoerg 
42*7330f729Sjoerg   return &getLangStandardForKind(K);
43*7330f729Sjoerg }
44*7330f729Sjoerg 
45*7330f729Sjoerg 
46