1f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar//===--- LangStandards.cpp - Language Standard Definitions ----------------===//
2f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar//
3f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar//                     The LLVM Compiler Infrastructure
4f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar//
5f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar// This file is distributed under the University of Illinois Open Source
6f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar// License. See LICENSE.TXT for details.
7f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar//
8f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar//===----------------------------------------------------------------------===//
9f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
10f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#include "clang/Frontend/LangStandard.h"
11f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#include "llvm/ADT/StringSwitch.h"
12f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#include "llvm/Support/ErrorHandling.h"
13f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbarusing namespace clang;
14f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbarusing namespace clang::frontend;
15f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
16f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#define LANGSTANDARD(id, name, desc, features) \
1768f7a2426227476bcfa33ada70b708c82419dfdcNuno Lopes  static const LangStandard Lang_##id = { name, desc, features };
18f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#include "clang/Frontend/LangStandards.def"
19f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
20f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbarconst LangStandard &LangStandard::getLangStandardForKind(Kind K) {
21f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar  switch (K) {
22f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar  case lang_unspecified:
2383e7a78a9fa3fc495a575bca0e3d4d7ce26184efChris Lattner    llvm::report_fatal_error("getLangStandardForKind() on unspecified kind");
24f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#define LANGSTANDARD(id, name, desc, features) \
25f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar    case lang_##id: return Lang_##id;
26f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#include "clang/Frontend/LangStandards.def"
27f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar  }
28561d3abc881033776ece385a01a510e1cbc1fa92David Blaikie  llvm_unreachable("Invalid language kind!");
29f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar}
30f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
315f9e272e632e951b1efe824cd16acb4d96077930Chris Lattnerconst LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
32f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar  Kind K = llvm::StringSwitch<Kind>(Name)
33f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#define LANGSTANDARD(id, name, desc, features) \
34f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar    .Case(name, lang_##id)
35f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar#include "clang/Frontend/LangStandards.def"
36f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar    .Default(lang_unspecified);
37f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar  if (K == lang_unspecified)
386bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines    return nullptr;
39f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
40f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar  return &getLangStandardForKind(K);
41f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar}
42f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
43f51ac1b3d0fd39853ba6c04e81149acbca6eead4Daniel Dunbar
44