ilya-golovenko created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
ilya-golovenko requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Google test matcher DeclKind uses NamedDecl::getDeclKindName() to compare 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 respective strings.

The test was passing on most platforms because compilers were able to coalesce 
these string literals.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90384

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


Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -59,7 +59,7 @@
 
 MATCHER_P(DeclKind, Kind, "") {
   if (NamedDecl *ND = dyn_cast<NamedDecl>(arg))
-    if (ND->getDeclKindName() == Kind)
+    if (ND->getDeclKindName() == llvm::StringRef(Kind))
       return true;
   if (auto *Stream = result_listener->stream()) {
     llvm::raw_os_ostream OS(*Stream);
@@ -104,8 +104,7 @@
          std::tie(Expected.HashLine, Expected.Written);
 }
 
-// FIXME: figure out why it fails on clang-ppc64le-rhel buildbot.
-TEST(ParsedASTTest, DISABLED_TopLevelDecls) {
+TEST(ParsedASTTest, TopLevelDecls) {
   TestTU TU;
   TU.HeaderCode = R"(
     int header1();


Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -59,7 +59,7 @@
 
 MATCHER_P(DeclKind, Kind, "") {
   if (NamedDecl *ND = dyn_cast<NamedDecl>(arg))
-    if (ND->getDeclKindName() == Kind)
+    if (ND->getDeclKindName() == llvm::StringRef(Kind))
       return true;
   if (auto *Stream = result_listener->stream()) {
     llvm::raw_os_ostream OS(*Stream);
@@ -104,8 +104,7 @@
          std::tie(Expected.HashLine, Expected.Written);
 }
 
-// FIXME: figure out why it fails on clang-ppc64le-rhel buildbot.
-TEST(ParsedASTTest, DISABLED_TopLevelDecls) {
+TEST(ParsedASTTest, TopLevelDecls) {
   TestTU TU;
   TU.HeaderCode = R"(
     int header1();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to