[PATCH] D59354: [clangd] Print arguments in template specializations

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 09:00:59 PDT 2019

kadircet marked 7 inline comments as done.
kadircet added inline comments.

Comment at: clang-tools-extra/clangd/AST.cpp:84
+    if (auto STL = TL.getAs<TemplateSpecializationTypeLoc>()) {
+      std::vector<TemplateArgumentLoc> ArgLocs;
+      for (unsigned I = 0; I < STL.getNumArgs(); I++)
ilya-biryukov wrote:
> NIT: use `SmallVector<8>` or some other small-enough number to avoid most allocs.
calling reserve beforehand

Comment at: clang-tools-extra/unittests/clangd/IndexTests.cpp:18
 #include "clang/Index/IndexSymbol.h"
+#include "gmock/gmock-generated-matchers.h"
 #include "gmock/gmock.h"
ilya-biryukov wrote:
> NIT: maybe remove it? clangd keeps adding those, but I don't think we actually want it: `gmock.h` should be enough
Should we add IWYU pragmas to those files? https://github.com/google/googlemock/blob/master/googlemock/include/gmock/gmock-generated-matchers.h

Comment at: clang-tools-extra/unittests/clangd/SymbolCollectorTests.cpp:417
+                ForCodeCompletion(true)),
+          AllOf(QName("Tmpl<int, bool, Bar, 3>"),
+                DeclRange(Header.range("specdecl")), ForCodeCompletion(false)),
ilya-biryukov wrote:
> Does it mean typing `bool` could potentially match `vector<bool>` in `workspaceSymbols` now?
> If that's the case we might start producing some noise.
unfortunately yes it does, what do you suggest? it seems like we can perform a "isprefix" check for symbols with template specs kind?

Comment at: clang/lib/AST/TypePrinter.cpp:1644
+                                llvm::raw_ostream &OS) {
+  A.getTypeSourceInfo()->getType().print(OS, PP);
ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > Maybe print the result of `getTypeLoc()` here, if it's available?
> > > Would produce results closer to the ones written in the code.
> > unfortunately it is not available.
> you mean the function to print a type loc or the type loc itself?
function to print a typeloc

  rG LLVM Github Monorepo



More information about the cfe-commits mailing list