[PATCH] D150683: [clangd] Tweak "provides" hover card when symbols have the same name

Viktoriia Bakalova via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 16 09:09:16 PDT 2023


VitaNuo accepted this revision.
VitaNuo added a comment.
This revision is now accepted and ready to land.

Thank you!



================
Comment at: clang-tools-extra/clangd/Hover.cpp:1539
+        Front, [&](llvm::StringRef Sym) { P.appendCode(Sym); },
+        [&] { P.appendText(", "); });
     if (UsedSymbolNames.size() > Front.size()) {
----------------
sammccall wrote:
> sammccall wrote:
> > VitaNuo wrote:
> > > What will this do if `Front` has an even number of elements? AFAIU the message will end in a comma then, which is not desirable.
> > llvm::interleave invokes the first callback for each element, and the second callback between subsequent elements. So this prints Front as a comma-separated list.
> > (It's very similar to the example in the llvm::interleave docs)
> Oh, the docs are confusing.
> 
> Given a list [a b c d] the relevant pairs are [a b];[b c];[c d]. Each one gets a comma in the middle, there are three commas.
Oh ok, I thought it was more basic, ie just applied the callbacks interchangeably. Thanks for the explanation!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150683/new/

https://reviews.llvm.org/D150683



More information about the cfe-commits mailing list