[PATCH] D94753: [clangd] exclude symbols from document outline which do not originate from the main file
Ilya Golovenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 15 03:02:31 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9cc221b99bec: [clangd] exclude symbols from document outline which do not originate from theā¦ (authored by ilya-golovenko).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94753/new/
https://reviews.llvm.org/D94753
Files:
clang-tools-extra/clangd/FindSymbols.cpp
clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -523,11 +523,13 @@
}
)cpp";
TU.Code = R"cpp(
+ int i; // declaration to finish preamble
#include "bar.h"
int test() {
}
)cpp";
- EXPECT_THAT(getSymbols(TU.build()), ElementsAre(WithName("test")));
+ EXPECT_THAT(getSymbols(TU.build()),
+ ElementsAre(WithName("i"), WithName("test")));
}
TEST(DocumentSymbols, Template) {
Index: clang-tools-extra/clangd/FindSymbols.cpp
===================================================================
--- clang-tools-extra/clangd/FindSymbols.cpp
+++ clang-tools-extra/clangd/FindSymbols.cpp
@@ -247,6 +247,10 @@
enum class VisitKind { No, OnlyDecl, OnlyChildren, DeclAndChildren };
void traverseDecl(Decl *D, std::vector<DocumentSymbol> &Results) {
+ // Skip symbols which do not originate from the main file.
+ if (!isInsideMainFile(D->getLocation(), AST.getSourceManager()))
+ return;
+
if (auto *Templ = llvm::dyn_cast<TemplateDecl>(D)) {
// TemplatedDecl might be null, e.g. concepts.
if (auto *TD = Templ->getTemplatedDecl())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94753.316888.patch
Type: text/x-patch
Size: 1327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210115/0753b52e/attachment.bin>
More information about the cfe-commits
mailing list