[clang-tools-extra] d084c42 - Investigate failure in rGdd13f45e04366cc4f648b57ec87d20a5569e27c3

Kirill Bobyrev via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 30 00:50:27 PDT 2021


Author: Kirill Bobyrev
Date: 2021-09-30T09:50:14+02:00
New Revision: d084c42bdfac4a5879bdabe645b14cf72f7685a7

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

LOG: Investigate failure in rGdd13f45e04366cc4f648b57ec87d20a5569e27c3

https://lab.llvm.org/buildbot/#/builders/123/builds/6406/steps/8/logs/stdio

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/Headers.cpp b/clang-tools-extra/clangd/Headers.cpp
index 33304b818d6f4..0b189e5dd42ee 100644
--- a/clang-tools-extra/clangd/Headers.cpp
+++ b/clang-tools-extra/clangd/Headers.cpp
@@ -168,8 +168,10 @@ IncludeStructure::getOrCreateID(const FileEntry *Entry) {
   auto R = NameToIndex.try_emplace(
       Entry->getName(),
       static_cast<IncludeStructure::HeaderID>(RealPathNames.size()));
-  if (R.second)
+  if (R.second) {
     RealPathNames.emplace_back();
+    FileEntryIDs.push_back(Entry->getUID());
+  }
   IncludeStructure::HeaderID Result = R.first->getValue();
   std::string &RealPathName = RealPathNames[static_cast<unsigned>(Result)];
   if (RealPathName.empty())

diff  --git a/clang-tools-extra/clangd/Headers.h b/clang-tools-extra/clangd/Headers.h
index 86294b9e2cda6..f322529e630cc 100644
--- a/clang-tools-extra/clangd/Headers.h
+++ b/clang-tools-extra/clangd/Headers.h
@@ -141,8 +141,16 @@ class IncludeStructure {
 
   std::vector<Inclusion> MainFileIncludes;
 
+  std::string dump() {
+    return "RealPathNames: " +
+           llvm::join(RealPathNames.begin(), RealPathNames.end(), ", ") +
+           "\nFileEntryIDs: " +
+           llvm::join(FileEntryIDs.begin(), FileEntryIDs.end(), ", ") + '\n';
+  }
+
 private:
   std::vector<std::string> RealPathNames; // In HeaderID order.
+  std::vector<unsigned> FileEntryIDs;     // In HeaderID order.
   // HeaderID maps the FileEntry::Name to the internal representation.
   // Identifying files in a way that persists from preamble build to subsequent
   // builds is surprisingly hard. FileID is unavailable in

diff  --git a/clang-tools-extra/clangd/unittests/HeadersTests.cpp b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
index 8a6f5e8b4619e..f6f1f4a5548d1 100644
--- a/clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -165,7 +165,8 @@ TEST_F(HeadersTest, CollectRewrittenAndResolved) {
                   AllOf(Written("\"sub/bar.h\""), Resolved(BarHeader))));
   EXPECT_THAT(Includes.includeDepth(getID(MainFile, Includes)),
               UnorderedElementsAre(Distance(getID(MainFile, Includes), 0u),
-                                   Distance(getID(BarHeader, Includes), 1u)));
+                                   Distance(getID(BarHeader, Includes), 1u)))
+      << Includes.dump();
 }
 
 TEST_F(HeadersTest, OnlyCollectInclusionsInMain) {
@@ -179,17 +180,19 @@ TEST_F(HeadersTest, OnlyCollectInclusionsInMain) {
 #include "bar.h"
 )cpp";
   auto Includes = collectIncludes();
-  EXPECT_THAT(Includes.MainFileIncludes,
-              UnorderedElementsAre(
-                  AllOf(Written("\"bar.h\""), Resolved(BarHeader))));
+  EXPECT_THAT(
+      Includes.MainFileIncludes,
+      UnorderedElementsAre(AllOf(Written("\"bar.h\""), Resolved(BarHeader))));
   EXPECT_THAT(Includes.includeDepth(getID(MainFile, Includes)),
               UnorderedElementsAre(Distance(getID(MainFile, Includes), 0u),
                                    Distance(getID(BarHeader, Includes), 1u),
-                                   Distance(getID(BazHeader, Includes), 2u)));
+                                   Distance(getID(BazHeader, Includes), 2u)))
+      << Includes.dump();
   // includeDepth() also works for non-main files.
   EXPECT_THAT(Includes.includeDepth(getID(BarHeader, Includes)),
               UnorderedElementsAre(Distance(getID(BarHeader, Includes), 0u),
-                                   Distance(getID(BazHeader, Includes), 1u)));
+                                   Distance(getID(BazHeader, Includes), 1u)))
+      << Includes.dump();
 }
 
 TEST_F(HeadersTest, PreambleIncludesPresentOnce) {
@@ -240,7 +243,7 @@ TEST_F(HeadersTest, IncludedFilesGraph) {
                    {getID(BarHeader, Includes), getID(FooHeader, Includes)}},
                   {getID(FooHeader, Includes),
                    {getID(BarHeader, Includes), getID(BazHeader, Includes)}}};
-  EXPECT_EQ(Includes.IncludeChildren, Expected);
+  EXPECT_EQ(Includes.IncludeChildren, Expected) << Includes.dump();
 }
 
 TEST_F(HeadersTest, IncludeDirective) {

diff  --git a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
index 9195865294f19..dde33711d6a3d 100644
--- a/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -517,7 +517,7 @@ TEST(ParsedASTTest, PatchesAdditionalIncludes) {
   ASSERT_TRUE(MainFE);
   auto MainID = Includes.getID(*MainFE);
   auto AuxFE = FM.getFile(testPath("sub/aux.h"));
-  ASSERT_TRUE(AuxFE);
+  ASSERT_TRUE(AuxFE) << Includes.dump();
   auto AuxID = Includes.getID(*AuxFE);
   EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(*AuxID));
 }


        


More information about the cfe-commits mailing list