[PATCH] D133423: [clangd] Improve Selection testcase, pin to C++17
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 7 07:00:34 PDT 2022
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
17 vs 14 have different ASTs, this causes D131465 <https://reviews.llvm.org/D131465> to have to touch this test.
While here, make sure we're being clear about *which* nodes we're matching.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133423
Files:
clang-tools-extra/clangd/unittests/SelectionTests.cpp
Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -716,17 +716,23 @@
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());
+ EXPECT_EQ("ImplicitCastExpr", nodeKind(Str->Parent->Parent->Parent));
+ const SelectionTree::Node *ICE = Str->Parent->Parent->Parent;
+ 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133423.458445.patch
Type: text/x-patch
Size: 1437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220907/77b6b935/attachment.bin>
More information about the cfe-commits
mailing list