Skip to content

Commit 6d15a28

Browse files
ilya-golovenkohokein
authored andcommitted
[clangd] Fix ParsedASTTest.TopLevelDecls test.
Google test matcher `DeclKind` uses `NamedDecl::getDeclKindName()` to compare its result with expected declaration name. Both, returned value of this function and the expected kind name argument have type `const char *`, so this matcher effectively compares two pointers instead of the respective strings. The test was passing on most platforms because compilers mostly were able to coalesce these string literals. Patch By: Ilya Golovenko Reviewed By: hokein Differential Revision: https://reviews.llvm.org/D90384
1 parent 40f7ac1 commit 6d15a28

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

clang-tools-extra/clangd/unittests/ParsedASTTests.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ MATCHER_P(DeclNamed, Name, "") {
5959

6060
MATCHER_P(DeclKind, Kind, "") {
6161
if (NamedDecl *ND = dyn_cast<NamedDecl>(arg))
62-
if (ND->getDeclKindName() == Kind)
62+
if (ND->getDeclKindName() == llvm::StringRef(Kind))
6363
return true;
6464
if (auto *Stream = result_listener->stream()) {
6565
llvm::raw_os_ostream OS(*Stream);
@@ -104,8 +104,7 @@ MATCHER(EqInc, "") {
104104
std::tie(Expected.HashLine, Expected.Written);
105105
}
106106

107-
// FIXME: figure out why it fails on clang-ppc64le-rhel buildbot.
108-
TEST(ParsedASTTest, DISABLED_TopLevelDecls) {
107+
TEST(ParsedASTTest, TopLevelDecls) {
109108
TestTU TU;
110109
TU.HeaderCode = R"(
111110
int header1();

0 commit comments

Comments
 (0)