This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa0cf2b8f712e: [clangd][NFC] Remove unnecessary vector. (authored by njames93).
Changed prior to commit: https://reviews.llvm.org/D92986?vs=310729&id=310879#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D92986/new/ 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> 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, 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,
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> 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, 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