mirror of
https://github.com/llvm/llvm-project.git
synced 2025-05-05 09:26:05 +00:00

We already prohibited this in most cases (in r130710), but had some bugs in our enforcement of this rule. Specifically, this prevents the following combinations: * -x c -std=clN.M, which would previously effectively act as if -x cl were used, despite the input being a C source file. (-x cl -std=cNN continues to be disallowed.) * -x c++ -std=cuda, which would previously select C++98 + CUDA, despite that not being a C++ standard. (-x cuda -std=c++NN is still permitted, and selects CUDA with the given C++ standard as its base language. -x cuda -std=cuda is still supported with the meaning of CUDA + C++98.) * -x renderscript -std=c++NN, which would previously form a hybrid "C++ with RenderScript extensions" language. We could support such a thing, but shouldn't do so by accident. llvm-svn: 301497
44 lines
1.4 KiB
C++
44 lines
1.4 KiB
C++
//===--- LangStandards.cpp - Language Standard Definitions ----------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "clang/Frontend/LangStandard.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
using namespace clang;
|
|
using namespace clang::frontend;
|
|
|
|
#define LANGSTANDARD(id, name, lang, desc, features) \
|
|
static const LangStandard Lang_##id = { name, desc, features, InputKind::lang };
|
|
#include "clang/Frontend/LangStandards.def"
|
|
|
|
const LangStandard &LangStandard::getLangStandardForKind(Kind K) {
|
|
switch (K) {
|
|
case lang_unspecified:
|
|
llvm::report_fatal_error("getLangStandardForKind() on unspecified kind");
|
|
#define LANGSTANDARD(id, name, lang, desc, features) \
|
|
case lang_##id: return Lang_##id;
|
|
#include "clang/Frontend/LangStandards.def"
|
|
}
|
|
llvm_unreachable("Invalid language kind!");
|
|
}
|
|
|
|
const LangStandard *LangStandard::getLangStandardForName(StringRef Name) {
|
|
Kind K = llvm::StringSwitch<Kind>(Name)
|
|
#define LANGSTANDARD(id, name, lang, desc, features) \
|
|
.Case(name, lang_##id)
|
|
#include "clang/Frontend/LangStandards.def"
|
|
.Default(lang_unspecified);
|
|
if (K == lang_unspecified)
|
|
return nullptr;
|
|
|
|
return &getLangStandardForKind(K);
|
|
}
|
|
|
|
|