clang  14.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 
17 namespace 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.
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 ||
43  }
44 
45  bool isCXX14OrLater() const {
46  return Language == Lang_CXX14 || Language == Lang_CXX17 ||
48  }
49 
50  bool isCXX17OrLater() const {
51  return Language == Lang_CXX17 || Language == Lang_CXX20;
52  }
53 
54  bool isCXX20OrLater() const { return Language == Lang_CXX20; }
55 
57  return Language == Lang_CXX03 || Language == Lang_CXX11 ||
59  }
60 
62  return Target == "x86_64-pc-win32-msvc";
63  }
64 
65  std::vector<std::string> getCommandLineArgs() const {
66  std::vector<std::string> Result = getCommandLineArgsForTesting(Language);
67  Result.push_back("-target");
68  Result.push_back(Target);
69  return Result;
70  }
71 
73  std::string Result;
74  llvm::raw_string_ostream OS(Result);
75  OS << "{ Language=" << Language << ", Target=" << Target << " }";
76  return OS.str();
77  }
78 
79  friend std::ostream &operator<<(std::ostream &OS,
80  const TestClangConfig &ClangConfig) {
81  return OS << ClangConfig.toString();
82  }
83 };
84 
85 } // end namespace clang
86 
87 #endif
clang::TestClangConfig
A Clang configuration for end-to-end tests that can be converted to command line arguments for the dr...
Definition: TestClangConfig.h:24
clang::TestClangConfig::Target
std::string Target
The argument of the -target command line flag.
Definition: TestClangConfig.h:28
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::Lang_CXX14
@ Lang_CXX14
Definition: CommandLineArgs.h:28
clang::TestClangConfig::isCXX14OrLater
bool isCXX14OrLater() const
Definition: TestClangConfig.h:45
clang::TestClangConfig::hasDelayedTemplateParsing
bool hasDelayedTemplateParsing() const
Definition: TestClangConfig.h:61
clang::TestClangConfig::supportsCXXDynamicExceptionSpecification
bool supportsCXXDynamicExceptionSpecification() const
Definition: TestClangConfig.h:56
clang::Lang_CXX20
@ Lang_CXX20
Definition: CommandLineArgs.h:30
clang::TestClangConfig::toString
std::string toString() const
Definition: TestClangConfig.h:72
clang::TestClangConfig::getCommandLineArgs
std::vector< std::string > getCommandLineArgs() const
Definition: TestClangConfig.h:65
clang::TestLanguage
TestLanguage
Definition: CommandLineArgs.h:23
clang::getCommandLineArgsForTesting
std::vector< std::string > getCommandLineArgsForTesting(TestLanguage Lang)
Definition: CommandLineArgs.cpp:14
clang::TestClangConfig::isCXX
bool isCXX() const
Definition: TestClangConfig.h:34
clang::TestClangConfig::isC
bool isC() const
Definition: TestClangConfig.h:30
clang::TestClangConfig::isCXX11OrLater
bool isCXX11OrLater() const
Definition: TestClangConfig.h:40
clang::Lang_CXX11
@ Lang_CXX11
Definition: CommandLineArgs.h:27
clang::Lang_C89
@ Lang_C89
Definition: CommandLineArgs.h:24
clang::TestClangConfig::operator<<
friend std::ostream & operator<<(std::ostream &OS, const TestClangConfig &ClangConfig)
Definition: TestClangConfig.h:79
clang::TestClangConfig::Language
TestLanguage Language
Definition: TestClangConfig.h:25
clang::Language
Language
The language for the input, used to select and validate the language standard and possible actions.
Definition: LangStandard.h:19
clang::TestClangConfig::isC99OrLater
bool isC99OrLater() const
Definition: TestClangConfig.h:32
clang::Lang_CXX17
@ Lang_CXX17
Definition: CommandLineArgs.h:29
clang::Lang_C99
@ Lang_C99
Definition: CommandLineArgs.h:25
clang
Definition: CalledOnceCheck.h:17
CommandLineArgs.h
clang::TestClangConfig::isCXX17OrLater
bool isCXX17OrLater() const
Definition: TestClangConfig.h:50
clang::TestClangConfig::isCXX20OrLater
bool isCXX20OrLater() const
Definition: TestClangConfig.h:54
clang::Lang_CXX03
@ Lang_CXX03
Definition: CommandLineArgs.h:26