[PATCH] D95942: [clangd] Deduplicate scopes in IncludeFixer queries
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 3 05:09:41 PST 2021
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95942
Files:
clang-tools-extra/clangd/IncludeFixer.cpp
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===================================================================
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -40,6 +40,7 @@
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
+#include <set>
#include <vector>
namespace clang {
@@ -313,18 +314,18 @@
std::vector<std::string>
collectAccessibleScopes(Sema &Sem, const DeclarationNameInfo &Typo, Scope *S,
Sema::LookupNameKind LookupKind) {
- std::vector<std::string> Scopes;
VisitedContextCollector Collector;
Sem.LookupVisibleDecls(S, LookupKind, Collector,
/*IncludeGlobalScope=*/false,
/*LoadExternal=*/false);
- Scopes.push_back("");
+ std::set<std::string> Scopes;
+ Scopes.insert("");
for (const auto *Ctx : Collector.takeVisitedContexts()) {
if (isa<NamespaceDecl>(Ctx))
- Scopes.push_back(printNamespaceScope(*Ctx));
+ Scopes.insert(printNamespaceScope(*Ctx));
}
- return Scopes;
+ return {Scopes.begin(), Scopes.end()};
}
class IncludeFixer::UnresolvedNameRecorder : public ExternalSemaSource {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95942.321064.patch
Type: text/x-patch
Size: 1233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210203/4cef69d3/attachment.bin>
More information about the cfe-commits
mailing list