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 20 const LangStandard &LangStandard::getLangStandardForKind(Kind K) { 21 switch (K) { 22 default: 23 llvm_unreachable("Invalid language kind!"); 24 case lang_unspecified: 25 llvm::report_fatal_error("getLangStandardForKind() on unspecified kind"); 26 #define LANGSTANDARD(id, name, desc, features) \ 27 case lang_##id: return Lang_##id; 28 #include "clang/Frontend/LangStandards.def" 29 } 30 } 31 32 const LangStandard *LangStandard::getLangStandardForName(llvm::StringRef Name) { 33 Kind K = llvm::StringSwitch<Kind>(Name) 34 #define LANGSTANDARD(id, name, desc, features) \ 35 .Case(name, lang_##id) 36 #include "clang/Frontend/LangStandards.def" 37 .Default(lang_unspecified); 38 if (K == lang_unspecified) 39 return 0; 40 41 return &getLangStandardForKind(K); 42 } 43 44 45