clang API Documentation
00001 //===--- LangStandards.cpp - Language Standard Definitions ----------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 00010 #include "clang/Frontend/LangStandard.h" 00011 #include "llvm/ADT/StringSwitch.h" 00012 #include "llvm/Support/ErrorHandling.h" 00013 using namespace clang; 00014 using namespace clang::frontend; 00015 00016 #define LANGSTANDARD(id, name, desc, features) \ 00017 static const LangStandard Lang_##id = { name, desc, features }; 00018 #include "clang/Frontend/LangStandards.def" 00019 00020 const LangStandard &LangStandard::getLangStandardForKind(Kind K) { 00021 switch (K) { 00022 case lang_unspecified: 00023 llvm::report_fatal_error("getLangStandardForKind() on unspecified kind"); 00024 #define LANGSTANDARD(id, name, desc, features) \ 00025 case lang_##id: return Lang_##id; 00026 #include "clang/Frontend/LangStandards.def" 00027 } 00028 llvm_unreachable("Invalid language kind!"); 00029 } 00030 00031 const LangStandard *LangStandard::getLangStandardForName(StringRef Name) { 00032 Kind K = llvm::StringSwitch<Kind>(Name) 00033 #define LANGSTANDARD(id, name, desc, features) \ 00034 .Case(name, lang_##id) 00035 #include "clang/Frontend/LangStandards.def" 00036 .Default(lang_unspecified); 00037 if (K == lang_unspecified) 00038 return nullptr; 00039 00040 return &getLangStandardForKind(K); 00041 } 00042 00043