[PATCH] D52445: [Index] Use locations to uniquify function-scope BindingDecl USR

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 24 16:22:36 PDT 2018


MaskRay created this revision.
MaskRay added reviewers: akyrtzi, arphaman.
Herald added a subscriber: cfe-commits.

This makes BindingDecl's of the same name have different USRs, so that references can be correctly attributed.

  int a[1] = {};
  { auto [x] = a; x; }
  { auto [x] = a; x; }


Repository:
  rC Clang

https://reviews.llvm.org/D52445

Files:
  lib/Index/USRGeneration.cpp


Index: lib/Index/USRGeneration.cpp
===================================================================
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -97,6 +97,7 @@
   void VisitTypedefDecl(const TypedefDecl *D);
   void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
   void VisitVarDecl(const VarDecl *D);
+  void VisitBindingDecl(const BindingDecl *D);
   void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
   void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
@@ -334,6 +335,12 @@
   }
 }
 
+void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
+  if (D->getParentFunctionOrMethod() && GenLoc(D, /*IncludeOffset=*/true))
+    return;
+  VisitNamedDecl(D);
+}
+
 void USRGenerator::VisitNonTypeTemplateParmDecl(
                                         const NonTypeTemplateParmDecl *D) {
   GenLoc(D, /*IncludeOffset=*/true);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52445.166782.patch
Type: text/x-patch
Size: 980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180924/76b72bbc/attachment-0001.bin>


More information about the cfe-commits mailing list