clang 19.0.0git
TestClangConfig.h
Go to the documentation of this file.
1//===--- TestClangConfig.h ------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TESTING_TESTCLANGCONFIG_H
10#define LLVM_CLANG_TESTING_TESTCLANGCONFIG_H
11
13#include "llvm/Support/raw_ostream.h"
14#include <string>
15#include <vector>
16
17namespace clang {
18
19/// A Clang configuration for end-to-end tests that can be converted to
20/// command line arguments for the driver.
21///
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.
26
27 /// The argument of the `-target` command line flag.
28 std::string Target;
29
30 bool isC() const { return Language == Lang_C89 || Language == Lang_C99; }
31
32 bool isC99OrLater() const { return Language == Lang_C99; }
33
34 bool isCXX() const {
35 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
38 }
39
40 bool isCXX11OrLater() const {
41 return Language == Lang_CXX11 || Language == Lang_CXX14 ||
44 }
45
46 bool isCXX14OrLater() const {
47 return Language == Lang_CXX14 || Language == Lang_CXX17 ||
49 }
50
51 bool isCXX17OrLater() const {
52 return Language == Lang_CXX17 || Language == Lang_CXX20 ||
54 }
55
56 bool isCXX20OrLater() const {
57 return Language == Lang_CXX20 || Language == Lang_CXX23;
58 }
59
60 bool isCXX23OrLater() const { return Language == Lang_CXX23; }
61
63 return Language == Lang_CXX03 || Language == Lang_CXX11 ||
65 }
66
68 return Target == "x86_64-pc-win32-msvc";
69 }
70
71 std::vector<std::string> getCommandLineArgs() const {
72 std::vector<std::string> Result = getCommandLineArgsForTesting(Language);
73 Result.push_back("-target");
74 Result.push_back(Target);
75 return Result;
76 }
77
78 std::string toString() const {
79 std::string Result;
80 llvm::raw_string_ostream OS(Result);
81 OS << "{ Language=" << Language << ", Target=" << Target << " }";
82 return Result;
83 }
84
85 friend std::ostream &operator<<(std::ostream &OS,
86 const TestClangConfig &ClangConfig) {
87 return OS << ClangConfig.toString();
88 }
89};
90
91} // end namespace clang
92
93#endif
llvm::MachO::Target Target
Definition: MachO.h:47
The JSON file list parser is used to communicate input to InstallAPI.
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:23
@ Result
The result type of a method or function.
std::vector< std::string > getCommandLineArgsForTesting(TestLanguage Lang)
A Clang configuration for end-to-end tests that can be converted to command line arguments for the dr...
std::vector< std::string > getCommandLineArgs() const
bool isCXX17OrLater() const
bool isCXX11OrLater() const
bool isCXX23OrLater() const
std::string toString() const
bool isCXX14OrLater() const
std::string Target
The argument of the -target command line flag.
bool isCXX20OrLater() const
bool supportsCXXDynamicExceptionSpecification() const
friend std::ostream & operator<<(std::ostream &OS, const TestClangConfig &ClangConfig)
bool hasDelayedTemplateParsing() const