[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG3c6a7b0045af: [clangd] Revert the symbol collector behavior to old pre-include-cleaner… (authored by VitaNuo). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156403/new/ https://reviews.llvm.org/D156403 Files: clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/index/SymbolCollector.h clang-tools-extra/clangd/unittests/FileIndexTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1592,7 +1592,7 @@ includeHeader("\"the/good/header.h\""; } -TEST_F(SymbolCollectorTest, IWYUPragmaExport) { +TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) { CollectorOpts.CollectIncludePath = true; const std::string Header = R"cpp(#pragma once #include "exporter.h" Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp === --- clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -239,7 +239,7 @@ ""); } -TEST(FileIndexTest, IWYUPragmaExport) { +TEST(FileIndexTest, DISABLED_IWYUPragmaExport) { FileIndex M; TestTU File; Index: clang-tools-extra/clangd/index/SymbolCollector.h === --- clang-tools-extra/clangd/index/SymbolCollector.h +++ clang-tools-extra/clangd/index/SymbolCollector.h @@ -175,11 +175,6 @@ void setIncludeLocation(const Symbol , SourceLocation, const include_cleaner::Symbol ); - // Providers for Symbol.IncludeHeaders. - // The final spelling is calculated in finish(). - llvm::DenseMap> - SymbolProviders; - // Files which contain ObjC symbols. // This is finalized and used in finish(). llvm::DenseSet FilesWithObjCConstructs; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp === --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -36,6 +36,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Lex/Token.h" #include "clang/Tooling/Inclusions/HeaderAnalysis.h" +#include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -836,14 +837,25 @@ // Use the expansion location to get the #include header since this is // where the symbol is exposed. IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first; +} - auto [It, Inserted] = SymbolProviders.try_emplace(S.ID); - if (Inserted) { -auto Headers = -include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes); -if (!Headers.empty()) - It->second = Headers.front(); - } +llvm::StringRef getStdHeader(const Symbol *S, const LangOptions ) { + tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX; +if (LangOpts.C11) + Lang = tooling::stdlib::Lang::C; +else if(!LangOpts.CPlusPlus) + return ""; + +if (S->Scope == "std::" && S->Name == "move") { + if (!S->Signature.contains(',')) +return ""; + return ""; +} + +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang)) + if (auto Header = StdSym->header()) + return Header->name(); +return ""; } void SymbolCollector::finish() { @@ -869,16 +881,13 @@ } } llvm::DenseMap FileToContainsImportsOrObjC; - llvm::DenseMap HeaderSpelling; // Fill in IncludeHeaders. // We delay this until end of TU so header guards are all resolved. - for (const auto &[SID, OptionalProvider] : SymbolProviders) { + for (const auto &[SID, FID] : IncludeFiles) { const Symbol *S = Symbols.find(SID); if (!S) continue; -assert(IncludeFiles.find(SID) != IncludeFiles.end()); -const auto FID = IncludeFiles.at(SID); // Determine if the FID is #include'd or #import'ed. Symbol::IncludeDirective Directives = Symbol::Invalid; auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind); @@ -898,54 +907,20 @@ if (Directives == Symbol::Invalid) continue; -// Use the include location-based logic for Objective-C symbols. -if (Directives & Symbol::Import) { - if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID); - !IncludeHeader.empty()) { -auto NewSym = *S; -NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); -Symbols.insert(NewSym); - } -
[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
kadircet added inline comments. Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:842 - auto [It, Inserted] = SymbolProviders.try_emplace(S.ID); - if (Inserted) { -auto Headers = -include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes); -if (!Headers.empty()) - It->second = Headers.front(); - } +llvm::StringRef getStdHeader(const Symbol *S, const LangOptions ) { + tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX; can you also move this into an anonymous namespace? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156403/new/ https://reviews.llvm.org/D156403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
VitaNuo updated this revision to Diff 544689. VitaNuo marked an inline comment as done. VitaNuo added a comment. Address comment. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156403/new/ https://reviews.llvm.org/D156403 Files: clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/index/SymbolCollector.h clang-tools-extra/clangd/unittests/FileIndexTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1592,7 +1592,7 @@ includeHeader("\"the/good/header.h\""; } -TEST_F(SymbolCollectorTest, IWYUPragmaExport) { +TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) { CollectorOpts.CollectIncludePath = true; const std::string Header = R"cpp(#pragma once #include "exporter.h" Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp === --- clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -239,7 +239,7 @@ ""); } -TEST(FileIndexTest, IWYUPragmaExport) { +TEST(FileIndexTest, DISABLED_IWYUPragmaExport) { FileIndex M; TestTU File; Index: clang-tools-extra/clangd/index/SymbolCollector.h === --- clang-tools-extra/clangd/index/SymbolCollector.h +++ clang-tools-extra/clangd/index/SymbolCollector.h @@ -175,11 +175,6 @@ void setIncludeLocation(const Symbol , SourceLocation, const include_cleaner::Symbol ); - // Providers for Symbol.IncludeHeaders. - // The final spelling is calculated in finish(). - llvm::DenseMap> - SymbolProviders; - // Files which contain ObjC symbols. // This is finalized and used in finish(). llvm::DenseSet FilesWithObjCConstructs; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp === --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -36,6 +36,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Lex/Token.h" #include "clang/Tooling/Inclusions/HeaderAnalysis.h" +#include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -836,14 +837,25 @@ // Use the expansion location to get the #include header since this is // where the symbol is exposed. IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first; +} - auto [It, Inserted] = SymbolProviders.try_emplace(S.ID); - if (Inserted) { -auto Headers = -include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes); -if (!Headers.empty()) - It->second = Headers.front(); - } +llvm::StringRef getStdHeader(const Symbol *S, const LangOptions ) { + tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX; +if (LangOpts.C11) + Lang = tooling::stdlib::Lang::C; +else if(!LangOpts.CPlusPlus) + return ""; + +if (S->Scope == "std::" && S->Name == "move") { + if (!S->Signature.contains(',')) +return ""; + return ""; +} + +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang)) + if (auto Header = StdSym->header()) + return Header->name(); +return ""; } void SymbolCollector::finish() { @@ -869,16 +881,13 @@ } } llvm::DenseMap FileToContainsImportsOrObjC; - llvm::DenseMap HeaderSpelling; // Fill in IncludeHeaders. // We delay this until end of TU so header guards are all resolved. - for (const auto &[SID, OptionalProvider] : SymbolProviders) { + for (const auto &[SID, FID] : IncludeFiles) { const Symbol *S = Symbols.find(SID); if (!S) continue; -assert(IncludeFiles.find(SID) != IncludeFiles.end()); -const auto FID = IncludeFiles.at(SID); // Determine if the FID is #include'd or #import'ed. Symbol::IncludeDirective Directives = Symbol::Invalid; auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind); @@ -898,54 +907,20 @@ if (Directives == Symbol::Invalid) continue; -// Use the include location-based logic for Objective-C symbols. -if (Directives & Symbol::Import) { - if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID); - !IncludeHeader.empty()) { -auto NewSym = *S; -NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); -Symbols.insert(NewSym); - } - // FIXME: use providers from include-cleaner library once it's polished - // for Objective-C. - continue; -} - -
[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
kadircet accepted this revision. kadircet added inline comments. This revision is now accepted and ready to land. Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:901 } +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang)) + if (auto Header = StdSym->header()) we shouldn't be overriding the include header if it's already set above. also i think it would be easier to have this out of the way so that reverting to old behaviour is easier: ``` llvm::StringRef getStdHeader(const Symbol *S, const LanguageOptions ) { tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX; if (ASTCtx->getLangOpts().C11) Lang = tooling::stdlib::Lang::C; else if(!ASTCtx->getLangOpts().CPlusPlus) return ""; if (S->Scope == "std::" && S->Name == "move") { if (!S->Signature.contains(',')) return ""; return ""; } if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang)) if (auto Header = StdSym->header()) return Header->name(); return ""; } ``` Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156403/new/ https://reviews.llvm.org/D156403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
VitaNuo updated this revision to Diff 544684. VitaNuo marked 6 inline comments as done. VitaNuo added a comment. Address comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156403/new/ https://reviews.llvm.org/D156403 Files: clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/index/SymbolCollector.h clang-tools-extra/clangd/unittests/FileIndexTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1592,7 +1592,7 @@ includeHeader("\"the/good/header.h\""; } -TEST_F(SymbolCollectorTest, IWYUPragmaExport) { +TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) { CollectorOpts.CollectIncludePath = true; const std::string Header = R"cpp(#pragma once #include "exporter.h" Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp === --- clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -239,7 +239,7 @@ ""); } -TEST(FileIndexTest, IWYUPragmaExport) { +TEST(FileIndexTest, DISABLED_IWYUPragmaExport) { FileIndex M; TestTU File; Index: clang-tools-extra/clangd/index/SymbolCollector.h === --- clang-tools-extra/clangd/index/SymbolCollector.h +++ clang-tools-extra/clangd/index/SymbolCollector.h @@ -175,11 +175,6 @@ void setIncludeLocation(const Symbol , SourceLocation, const include_cleaner::Symbol ); - // Providers for Symbol.IncludeHeaders. - // The final spelling is calculated in finish(). - llvm::DenseMap> - SymbolProviders; - // Files which contain ObjC symbols. // This is finalized and used in finish(). llvm::DenseSet FilesWithObjCConstructs; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp === --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -36,6 +36,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Lex/Token.h" #include "clang/Tooling/Inclusions/HeaderAnalysis.h" +#include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -836,14 +837,6 @@ // Use the expansion location to get the #include header since this is // where the symbol is exposed. IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first; - - auto [It, Inserted] = SymbolProviders.try_emplace(S.ID); - if (Inserted) { -auto Headers = -include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes); -if (!Headers.empty()) - It->second = Headers.front(); - } } void SymbolCollector::finish() { @@ -869,16 +862,13 @@ } } llvm::DenseMap FileToContainsImportsOrObjC; - llvm::DenseMap HeaderSpelling; // Fill in IncludeHeaders. // We delay this until end of TU so header guards are all resolved. - for (const auto &[SID, OptionalProvider] : SymbolProviders) { + for (const auto &[SID, FID] : IncludeFiles) { const Symbol *S = Symbols.find(SID); if (!S) continue; -assert(IncludeFiles.find(SID) != IncludeFiles.end()); -const auto FID = IncludeFiles.at(SID); // Determine if the FID is #include'd or #import'ed. Symbol::IncludeDirective Directives = Symbol::Invalid; auto CollectDirectives = shouldCollectIncludePath(S->SymInfo.Kind); @@ -898,54 +888,32 @@ if (Directives == Symbol::Invalid) continue; -// Use the include location-based logic for Objective-C symbols. -if (Directives & Symbol::Import) { - if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID); - !IncludeHeader.empty()) { -auto NewSym = *S; -NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); -Symbols.insert(NewSym); - } - // FIXME: use providers from include-cleaner library once it's polished - // for Objective-C. - continue; +// FIXME: Use the include-cleaner library instead. +tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX; +if (ASTCtx->getLangOpts().C11) + Lang = tooling::stdlib::Lang::C; +llvm::StringRef IncludeHeader; +if (S->Scope == "std::" && S->Name == "move") { + IncludeHeader = ""; + if (S->Signature.contains(',')) +IncludeHeader = ""; } +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang)) + if (auto Header = StdSym->header()) +IncludeHeader = Header->name(); -
[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
kadircet added inline comments. Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:841-847 auto [It, Inserted] = SymbolProviders.try_emplace(S.ID); if (Inserted) { auto Headers = include_cleaner::headersForSymbol(Sym, SM, Opts.PragmaIncludes); if (!Headers.empty()) It->second = Headers.front(); } can you also get rid of this piece, and `SymbolProviders` map ? Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:873 llvm::DenseMap FileToContainsImportsOrObjC; llvm::DenseMap HeaderSpelling; // Fill in IncludeHeaders. we can drop this too Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:903-927 +// mapping inside the include-cleaner library again. +llvm::StringRef IncludeHeader; +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name)) + if (auto Header = StdSym->header()) +IncludeHeader = Header->name(); +if (S->Scope == "std::" && S->Name == "move") { + IncludeHeader = ""; rather than duplicating some of the checks, can we rewrite this block as: ``` llvm::StringRef IncludeHeader = getStdlibHeader(*S, ASTCtx->getLangOpts()); if (IncludeHeader.empty()) IncludeHeader = HeaderFileURIs->getIncludeHeader(FID); if (!IncludeHeader.empty()) { auto NewSym = *S; NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); Symbols.insert(NewSym); } ``` Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:905 +llvm::StringRef IncludeHeader; +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name)) + if (auto Header = StdSym->header()) let's pass in the language options from ASTCtx into here Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:908-912 +if (S->Scope == "std::" && S->Name == "move") { + IncludeHeader = ""; + if (S->Signature.contains(',')) +IncludeHeader = ""; +} i think the old order of, first dealing with `std::move` and then using `tooling::stdlib` is less error-prone and the order in which we apply the mapping in include-cleaner, so that would be a more compatible change going forward. Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:929-964 +// FIXME: use providers from include-cleaner library once it's polished +// for Objective-C. +continue; + +// FIXME: Re-enable for C++ code. The code below uses include-cleaner +// library but is currently unreachable due to regression. assert(Directives == Symbol::Include); let's drop this block to not create confusion Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D156403/new/ https://reviews.llvm.org/D156403 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
VitaNuo created this revision. Herald added subscribers: kadircet, arphaman. Herald added a project: All. VitaNuo requested review of this revision. Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov. Herald added a project: clang-tools-extra. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D156403 Files: clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/unittests/FileIndexTests.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1592,7 +1592,7 @@ includeHeader("\"the/good/header.h\""; } -TEST_F(SymbolCollectorTest, IWYUPragmaExport) { +TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) { CollectorOpts.CollectIncludePath = true; const std::string Header = R"cpp(#pragma once #include "exporter.h" Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp === --- clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -239,7 +239,7 @@ ""); } -TEST(FileIndexTest, IWYUPragmaExport) { +TEST(FileIndexTest, DISABLED_IWYUPragmaExport) { FileIndex M; TestTU File; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp === --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -36,6 +36,7 @@ #include "clang/Lex/Preprocessor.h" #include "clang/Lex/Token.h" #include "clang/Tooling/Inclusions/HeaderAnalysis.h" +#include "clang/Tooling/Inclusions/StandardLibrary.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" @@ -898,19 +899,39 @@ if (Directives == Symbol::Invalid) continue; -// Use the include location-based logic for Objective-C symbols. -if (Directives & Symbol::Import) { - if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID); - !IncludeHeader.empty()) { -auto NewSym = *S; -NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); -Symbols.insert(NewSym); - } - // FIXME: use providers from include-cleaner library once it's polished - // for Objective-C. +// FIXME: Remove the block below once we can rely on standard library +// mapping inside the include-cleaner library again. +llvm::StringRef IncludeHeader; +if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name)) + if (auto Header = StdSym->header()) +IncludeHeader = Header->name(); +if (S->Scope == "std::" && S->Name == "move") { + IncludeHeader = ""; + if (S->Signature.contains(',')) +IncludeHeader = ""; +} +if (!IncludeHeader.empty()) { + auto NewSym = *S; + NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); + Symbols.insert(NewSym); continue; } +// Use the old include location-based logic both for Objective-C and C++ +// symbols. +if (auto IncludeHeader = HeaderFileURIs->getIncludeHeader(FID); +!IncludeHeader.empty()) { + auto NewSym = *S; + NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives}); + Symbols.insert(NewSym); +} + +// FIXME: use providers from include-cleaner library once it's polished +// for Objective-C. +continue; + +// FIXME: Re-enable for C++ code. The code below uses include-cleaner +// library but is currently unreachable due to regression. assert(Directives == Symbol::Include); // For #include's, use the providers computed by the include-cleaner // library. Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp === --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -1592,7 +1592,7 @@ includeHeader("\"the/good/header.h\""; } -TEST_F(SymbolCollectorTest, IWYUPragmaExport) { +TEST_F(SymbolCollectorTest, DISABLED_IWYUPragmaExport) { CollectorOpts.CollectIncludePath = true; const std::string Header = R"cpp(#pragma once #include "exporter.h" Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp === --- clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -239,7 +239,7 @@ ""); } -TEST(FileIndexTest, IWYUPragmaExport) { +TEST(FileIndexTest, DISABLED_IWYUPragmaExport) { FileIndex M;