[clang-tools-extra] 6d15a28 - [clangd] Fix ParsedASTTest.TopLevelDecls test.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 1 23:37:27 PST 2020


Author: Ilya Golovenko
Date: 2020-11-02T08:37:04+01:00
New Revision: 6d15a28a853d5eb453d58324141c9ec75d55c2da

URL: https://github.com/llvm/llvm-project/commit/6d15a28a853d5eb453d58324141c9ec75d55c2da
DIFF: https://github.com/llvm/llvm-project/commit/6d15a28a853d5eb453d58324141c9ec75d55c2da.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
index 9b7b2e2dcd47..3fd7ded2b356 100644
--- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -59,7 +59,7 @@ MATCHER_P(DeclNamed, Name, "") {
 
 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 @@ MATCHER(EqInc, "") {
          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();


        


More information about the cfe-commits mailing list