diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp --- a/clang-tools-extra/clangd/index/SymbolCollector.cpp +++ b/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. diff --git a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp --- a/clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ b/clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -239,7 +239,7 @@ ""); } -TEST(FileIndexTest, IWYUPragmaExport) { +TEST(FileIndexTest, DISABLED_IWYUPragmaExport) { FileIndex M; TestTU File; diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp --- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ b/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"