2009-11-26 10:14:31 +08:00
|
|
|
//===--- LangStandards.cpp - Language Standard Definitions ----------------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2009-11-26 10:14:31 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Frontend/LangStandard.h"
|
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
using namespace clang;
|
|
|
|
using namespace clang::frontend;
|
|
|
|
|
2017-04-27 07:44:33 +08:00
|
|
|
#define LANGSTANDARD(id, name, lang, desc, features) \
|
|
|
|
static const LangStandard Lang_##id = { name, desc, features, InputKind::lang };
|
2009-11-26 10:14:31 +08:00
|
|
|
#include "clang/Frontend/LangStandards.def"
|
|
|
|
|
|
|
|
const LangStandard &LangStandard::getLangStandardForKind(Kind K) {
|
|
|
|
switch (K) {
|
|
|
|
case lang_unspecified:
|
2010-04-08 06:58:06 +08:00
|
|
|
llvm::report_fatal_error("getLangStandardForKind() on unspecified kind");
|
2017-04-27 07:44:33 +08:00
|
|
|
#define LANGSTANDARD(id, name, lang, desc, features) \
|
2009-11-26 10:14:31 +08:00
|
|
|
case lang_##id: return Lang_##id;
|
|
|
|
#include "clang/Frontend/LangStandards.def"
|
|
|
|
}
|
2012-01-17 10:30:50 +08:00
|
|
|
llvm_unreachable("Invalid language kind!");
|
2009-11-26 10:14:31 +08:00
|
|
|
}
|
|
|
|
|
2011-07-23 18:55:15 +08:00
|
|
|
const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
|
2009-11-26 10:14:31 +08:00
|
|
|
Kind K = llvm::StringSwitch<Kind>(Name)
|
2017-04-27 07:44:33 +08:00
|
|
|
#define LANGSTANDARD(id, name, lang, desc, features) \
|
2009-11-26 10:14:31 +08:00
|
|
|
.Case(name, lang_##id)
|
|
|
|
#include "clang/Frontend/LangStandards.def"
|
|
|
|
.Default(lang_unspecified);
|
|
|
|
if (K == lang_unspecified)
|
2014-05-22 12:46:25 +08:00
|
|
|
return nullptr;
|
2009-11-26 10:14:31 +08:00
|
|
|
|
|
|
|
return &getLangStandardForKind(K);
|
|
|
|
}
|
|
|
|
|
|
|
|
|