1 //===--- TestClangConfig.h ------------------------------------------------===//
3 // 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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TESTING_TESTCLANGCONFIG_H
10 #define LLVM_CLANG_TESTING_TESTCLANGCONFIG_H
12 #include "clang/Testing/CommandLineArgs.h"
13 #include "llvm/Support/raw_ostream.h"
19 /// A Clang configuration for end-to-end tests that can be converted to
20 /// command line arguments for the driver.
22 /// The configuration is represented as typed, named values, making it easier
23 /// and safer to work with compared to an array of string command line flags.
24 struct TestClangConfig {
25 TestLanguage Language;
27 /// The argument of the `-target` command line flag.
30 bool isC() const { return Language == Lang_C89 || Language == Lang_C99; }
32 bool isC99OrLater() const { return Language == Lang_C99; }
35 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
36 Language == Lang_CXX14 || Language == Lang_CXX17 ||
37 Language == Lang_CXX20;
40 bool isCXX11OrLater() const {
41 return Language == Lang_CXX11 || Language == Lang_CXX14 ||
42 Language == Lang_CXX17 || Language == Lang_CXX20;
45 bool isCXX14OrLater() const {
46 return Language == Lang_CXX14 || Language == Lang_CXX17 ||
47 Language == Lang_CXX20;
50 bool isCXX17OrLater() const {
51 return Language == Lang_CXX17 || Language == Lang_CXX20;
54 bool supportsCXXDynamicExceptionSpecification() const {
55 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
56 Language == Lang_CXX14;
59 bool hasDelayedTemplateParsing() const {
60 return Target == "x86_64-pc-win32-msvc";
63 std::vector<std::string> getCommandLineArgs() const {
64 std::vector<std::string> Result = getCommandLineArgsForTesting(Language);
65 Result.push_back("-target");
66 Result.push_back(Target);
70 std::string toString() const {
72 llvm::raw_string_ostream OS(Result);
73 OS << "{ Language=" << Language << ", Target=" << Target << " }";
77 friend std::ostream &operator<<(std::ostream &OS,
78 const TestClangConfig &ClangConfig) {
79 return OS << ClangConfig.toString();
83 } // end namespace clang