aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
diff options
context:
space:
mode:
authorJulian Schmidt <git.julian.schmidt@gmail.com>2024-09-27 13:03:23 +0200
committerGitHub <noreply@github.com>2024-09-27 13:03:23 +0200
commit7dfdca1961aadc75ca397818bfb9bd32f1879248 (patch)
treee30d669c95dc31aae996e98ac9652095937f51f3 /clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
parent3fee3e83a8a802cd23e79fbf2f1320bb8f961d0c (diff)
downloadllvm-7dfdca1961aadc75ca397818bfb9bd32f1879248.zip
llvm-7dfdca1961aadc75ca397818bfb9bd32f1879248.tar.gz
llvm-7dfdca1961aadc75ca397818bfb9bd32f1879248.tar.bz2
[clang][test] add TestLanguage.def to specify all tested language versions (#94243)
Adds a def file to have a single location where tested language versions are specified. Removes the need to update multiple locations in the testing infrastructure to add a new language version to be tested. Test instatiation can now include all languages without needing to specify them. This patch also adds pretty printing for instantiated test names. That means, that a test instantiated with C++23 will have the name `...TestSuite/TestName/CXX23` instead ending with some number (index of the argument for instantiation of the test), which provides a better experience when encountering a test failure with a specific language version. The suffix will also contain an `_win` if the target contains `win`. --------- Co-authored-by: Sirraide <aeternalmail@gmail.com>
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index f2eaf19..3295ad1 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1224,7 +1224,7 @@ TEST_P(ASTMatchersTest, CastExpression_MatchesImplicitCasts) {
}
TEST_P(ASTMatchersTest, CastExpr_DoesNotMatchNonCasts) {
- if (GetParam().Language == Lang_C89 || GetParam().Language == Lang_C99) {
+ if (GetParam().isC()) {
// This does have a cast in C
EXPECT_TRUE(matches("char c = '0';", implicitCastExpr()));
} else {
@@ -1678,7 +1678,7 @@ TEST_P(ASTMatchersTest, FunctionProtoType) {
}
TEST_P(ASTMatchersTest, FunctionProtoType_C) {
- if (!GetParam().isC()) {
+ if (!GetParam().isCOrEarlier(17)) {
return;
}
EXPECT_TRUE(notMatches("void f();", functionProtoType()));
@@ -2745,8 +2745,11 @@ TEST(MatchFinderAPI, MatchesDynamic) {
static std::vector<TestClangConfig> allTestClangConfigs() {
std::vector<TestClangConfig> all_configs;
- for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
- Lang_CXX14, Lang_CXX17, Lang_CXX20, Lang_CXX23}) {
+ for (TestLanguage lang : {
+#define TESTLANGUAGE(lang, version, std_flag, version_index) \
+ Lang_##lang##version,
+#include "clang/Testing/TestLanguage.def"
+ }) {
TestClangConfig config;
config.Language = lang;
@@ -2770,8 +2773,11 @@ static std::vector<TestClangConfig> allTestClangConfigs() {
return all_configs;
}
-INSTANTIATE_TEST_SUITE_P(ASTMatchersTests, ASTMatchersTest,
- testing::ValuesIn(allTestClangConfigs()));
+INSTANTIATE_TEST_SUITE_P(
+ ASTMatchersTests, ASTMatchersTest, testing::ValuesIn(allTestClangConfigs()),
+ [](const testing::TestParamInfo<TestClangConfig> &Info) {
+ return Info.param.toShortString();
+ });
} // namespace ast_matchers
} // namespace clang