llvm-project/clang/lib/Testing/CommandLineArgs.cpp
Dmitri Gribenko d559185aae Renamed Lang_C to Lang_C99, Lang_CXX to Lang_CXX03, and 2a to 20
Summary:
I think we would be better off with tests explicitly specifying the
language mode. Right now Lang_C means C99, but reads as "any C version",
or as "unspecified C version".

I also changed '-std=c++98' to '-std=c++03' because they are aliases (so
there is no difference in practice), because Clang implements C++03
rules in practice, and because 03 makes a nice sortable progression
between 03, 11, 14, 17, 20.

Reviewers: shafik, hlopko

Reviewed By: hlopko

Subscribers: jfb, martong, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81000
2020-06-02 16:31:20 +02:00

49 lines
1.3 KiB
C++

//===--- CommandLineArgs.cpp ----------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
#include "clang/Testing/CommandLineArgs.h"
#include "llvm/Support/ErrorHandling.h"
namespace clang {
std::vector<std::string> getCommandLineArgsForTesting(TestLanguage Lang) {
std::vector<std::string> Args;
// Test with basic arguments.
switch (Lang) {
case Lang_C89:
Args = {"-x", "c", "-std=c89"};
break;
case Lang_C99:
Args = {"-x", "c", "-std=c99"};
break;
case Lang_CXX03:
Args = {"-std=c++03", "-frtti"};
break;
case Lang_CXX11:
Args = {"-std=c++11", "-frtti"};
break;
case Lang_CXX14:
Args = {"-std=c++14", "-frtti"};
break;
case Lang_CXX17:
Args = {"-std=c++17", "-frtti"};
break;
case Lang_CXX20:
Args = {"-std=c++20", "-frtti"};
break;
case Lang_OBJCXX:
Args = {"-x", "objective-c++", "-frtti"};
break;
case Lang_OpenCL:
llvm_unreachable("Not implemented yet!");
}
return Args;
}
} // end namespace clang