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