[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.
Viktoriia Bakalova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 27 01:44:37 PDT 2023
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 @@
"<the/good/header.h>");
}
-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 = "<utility>";
+ if (S->Signature.contains(','))
+ IncludeHeader = "<algorithm>";
+ }
+ 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156403.544653.patch
Type: text/x-patch
Size: 3525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230727/187fed2e/attachment.bin>
More information about the cfe-commits
mailing list