[PATCH] D47623: [clangd] Avoid indexing decls associated with friend decls.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 1 09:23:43 PDT 2018


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

This looks OK, the asymmetry still seems a little odd to me and could be reduced a little.

(Please also resolve Ilya's question about references with him, I don't have a strong opinion)



================
Comment at: clangd/index/SymbolCollector.cpp:303
+  // canonical declaration in the index.
+  if (D->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None)
+    D = ASTNode.OrigD;
----------------
Ah, now I understand - we're picking another to use as canonical. But the exception for definitions should apply here too. And there's nothing special about *OrigD* that makes it a good pick for canonical.

For determinism, can we instead iterate over the redecls of D and pick the first one that's not a friend or is a definition?

(I'd pull that check out into a function `shouldSkipDecl` and rename the existing one `shouldSkipSymbol`, but up to you)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47623





More information about the cfe-commits mailing list