Author: Nathan James Date: 2020-12-10T14:59:17Z New Revision: a0cf2b8f712e0bca9185d77cf1def8160f165548
URL: https://github.com/llvm/llvm-project/commit/a0cf2b8f712e0bca9185d77cf1def8160f165548 DIFF: https://github.com/llvm/llvm-project/commit/a0cf2b8f712e0bca9185d77cf1def8160f165548.diff LOG: [clangd][NFC] Remove unnecessary vector. As pointed out in D92788. Reviewed By: kbobyrev Differential Revision: https://reviews.llvm.org/D92986 Added: Modified: clang-tools-extra/clangd/unittests/TestTU.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/unittests/TestTU.cpp b/clang-tools-extra/clangd/unittests/TestTU.cpp index 27019403ae85..3b1130444671 100644 --- a/clang-tools-extra/clangd/unittests/TestTU.cpp +++ b/clang-tools-extra/clangd/unittests/TestTU.cpp @@ -187,9 +187,6 @@ const Symbol &findSymbol(const SymbolSlab &Slab, llvm::StringRef QName) { } const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) { - llvm::SmallVector<llvm::StringRef> Components; - QName.split(Components, "::"); - auto &Ctx = AST.getASTContext(); auto LookupDecl = [&Ctx](const DeclContext &Scope, llvm::StringRef Name) -> const NamedDecl & { @@ -200,11 +197,13 @@ const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) { }; 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, Rest; + for (std::tie(Cur, Rest) = QName.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, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits