[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 04:57:40 PDT 2019


kadircet added inline comments.


================
Comment at: clang-tools-extra/clangd/AST.cpp:110
+
+static bool isAnonymous(const DeclarationName &N) {
+  return N.isIdentifier() && !N.getAsIdentifierInfo();
----------------
could you move this one back above `getQualifierLoc` ?


================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:415
 
 Optional<ReferenceLoc> refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor<Visitor> {
----------------
ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > This should return `SmallVector<ReferenceLoc, 2>` now, some declarations can have both decl and non-decl references.
> > Can you give some examples? It seems that non-decl references are handled by other `refIn*` functions.
> > 
> > ```
> > int Foo = OtherBar; // OtherBar is captured at the momment.
> > ```
> ```
> namespace $1[[a]] = $2[[std]];
> ```
> 
> `$1` is a declaration of a namespace alias.
> `$2` is a reference to namespace std.
I was just about to make the same point. After this patch lands I would like to detect `using namespace`s inside function body, and currently there is no way to distinguish between a usingdirective and a namespacealias. Since both is only referencing the target namespace.

So even if this starts reporting `$2` in the comment above, there should be a difference between that and `$3` in `using namespace $3[[std]];`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977





More information about the cfe-commits mailing list