[PATCH] D92986: [clangd][NFC] Remove unnecessary vector.
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 9 17:31:48 PST 2020
njames93 created this revision.
njames93 added reviewers: kbobyrev, sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
As pointed out in D92788 <https://reviews.llvm.org/D92788>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92986
Files:
clang-tools-extra/clangd/unittests/TestTU.cpp
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,9 +187,6 @@
}
const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
- llvm::SmallVector<llvm::StringRef, 4> Components;
- QName.split(Components, "::");
-
auto &Ctx = AST.getASTContext();
auto LookupDecl = [&Ctx](const DeclContext &Scope,
llvm::StringRef Name) -> const NamedDecl & {
@@ -200,11 +197,13 @@
};
const DeclContext *Scope = Ctx.getTranslationUnitDecl();
- for (auto NameIt = Components.begin(), End = Components.end() - 1;
- NameIt != End; ++NameIt) {
- Scope = &cast<DeclContext>(LookupDecl(*Scope, *NameIt));
+
+ StringRef Cur = QName, Rest;
+ for (std::tie(Cur, Rest) = Cur.split("::"); !Rest.empty();
+ std::tie(Cur, Rest) = Rest.split("::")) {
+ Scope = &cast<DeclContext>(LookupDecl(*Scope, Cur));
}
- return LookupDecl(*Scope, Components.back());
+ return LookupDecl(*Scope, Cur);
}
const NamedDecl &findDecl(ParsedAST &AST,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92986.310729.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201210/7b67a28d/attachment.bin>
More information about the cfe-commits
mailing list