blob: 05087eb41f01d8e560da59e6af10729e3b8ee558 [file] [log] [blame]
Daniel Dunbare0d81f22009-11-26 02:14:31 +00001//===--- LangStandards.cpp - Language Standard Definitions ----------------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Daniel Dunbare0d81f22009-11-26 02:14:31 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "clang/Frontend/LangStandard.h"
10#include "llvm/ADT/StringSwitch.h"
11#include "llvm/Support/ErrorHandling.h"
12using namespace clang;
13using namespace clang::frontend;
14
Richard Smithb0fe7042017-04-26 23:44:33 +000015#define LANGSTANDARD(id, name, lang, desc, features) \
16static const LangStandard Lang_##id = { name, desc, features, InputKind::lang };
Daniel Dunbare0d81f22009-11-26 02:14:31 +000017#include "clang/Frontend/LangStandards.def"
18
19const LangStandard &LangStandard::getLangStandardForKind(Kind K) {
20 switch (K) {
Daniel Dunbare0d81f22009-11-26 02:14:31 +000021 case lang_unspecified:
Chris Lattner4b73cfa2010-04-07 22:58:06 +000022 llvm::report_fatal_error("getLangStandardForKind() on unspecified kind");
Richard Smithb0fe7042017-04-26 23:44:33 +000023#define LANGSTANDARD(id, name, lang, desc, features) \
Daniel Dunbare0d81f22009-11-26 02:14:31 +000024 case lang_##id: return Lang_##id;
25#include "clang/Frontend/LangStandards.def"
26 }
David Blaikief47fa302012-01-17 02:30:50 +000027 llvm_unreachable("Invalid language kind!");
Daniel Dunbare0d81f22009-11-26 02:14:31 +000028}
29
Chris Lattner0e62c1c2011-07-23 10:55:15 +000030const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
Daniel Dunbare0d81f22009-11-26 02:14:31 +000031 Kind K = llvm::StringSwitch<Kind>(Name)
Richard Smithb0fe7042017-04-26 23:44:33 +000032#define LANGSTANDARD(id, name, lang, desc, features) \
Daniel Dunbare0d81f22009-11-26 02:14:31 +000033 .Case(name, lang_##id)
34#include "clang/Frontend/LangStandards.def"
35 .Default(lang_unspecified);
36 if (K == lang_unspecified)
Craig Topper49a27902014-05-22 04:46:25 +000037 return nullptr;
Daniel Dunbare0d81f22009-11-26 02:14:31 +000038
39 return &getLangStandardForKind(K);
40}
41
42