From 8af74da5bdbdccf13de84a4610ef75cd3dbac09e Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Wed, 7 Sep 2022 16:00:21 +0200 Subject: [PATCH] [clangd] Improve Selection testcase, pin to C++17 17 vs 14 have different ASTs, this causes D131465 to have to touch this test. While here, make sure we're being clear about *which* nodes we're matching. Differential Revision: https://reviews.llvm.org/D133423 --- clang-tools-extra/clangd/unittests/SelectionTests.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/SelectionTests.cpp b/clang-tools-extra/clangd/unittests/SelectionTests.cpp index f7a518f..b44d9a6 100644 --- a/clang-tools-extra/clangd/unittests/SelectionTests.cpp +++ b/clang-tools-extra/clangd/unittests/SelectionTests.cpp @@ -716,17 +716,23 @@ TEST(SelectionTest, Implicit) { int f(S); int x = f("^"); )cpp"; - auto AST = TestTU::withCode(Annotations(Test).code()).build(); + auto TU = TestTU::withCode(Annotations(Test).code()); + // C++14 AST contains some temporaries that C++17 elides. + TU.ExtraArgs.push_back("-std=c++17"); + auto AST = TU.build(); auto T = makeSelectionTree(Test, AST); const SelectionTree::Node *Str = T.commonAncestor(); EXPECT_EQ("StringLiteral", nodeKind(Str)) << "Implicit selected?"; EXPECT_EQ("ImplicitCastExpr", nodeKind(Str->Parent)); EXPECT_EQ("CXXConstructExpr", nodeKind(Str->Parent->Parent)); - EXPECT_EQ(Str, &Str->Parent->Parent->ignoreImplicit()) - << "Didn't unwrap " << nodeKind(&Str->Parent->Parent->ignoreImplicit()); + const SelectionTree::Node *ICE = Str->Parent->Parent->Parent; + EXPECT_EQ("ImplicitCastExpr", nodeKind(ICE)); + EXPECT_EQ("CallExpr", nodeKind(ICE->Parent)); + EXPECT_EQ(Str, &ICE->ignoreImplicit()) + << "Didn't unwrap " << nodeKind(&ICE->ignoreImplicit()); - EXPECT_EQ("CXXConstructExpr", nodeKind(&Str->outerImplicit())); + EXPECT_EQ(ICE, &Str->outerImplicit()); } TEST(SelectionTest, CreateAll) { -- 2.7.4