r324093 - [Index] fix USR generation for namespace{extern{X}}

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 2 06:13:37 PST 2018


Author: sammccall
Date: Fri Feb  2 06:13:37 2018
New Revision: 324093

URL: http://llvm.org/viewvc/llvm-project?rev=324093&view=rev
Log:
[Index] fix USR generation for namespace{extern{X}}

Added:
    cfe/trunk/test/Index/USR/linkage.cpp
Modified:
    cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=324093&r1=324092&r2=324093&view=diff
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Fri Feb  2 06:13:37 2018
@@ -103,7 +103,7 @@ public:
   void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D);
 
   void VisitLinkageSpecDecl(const LinkageSpecDecl *D) {
-    IgnoreResults = true;
+    IgnoreResults = true; // No USRs for linkage specs themselves.
   }
 
   void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
@@ -192,6 +192,8 @@ bool USRGenerator::ShouldGenerateLocatio
 void USRGenerator::VisitDeclContext(const DeclContext *DC) {
   if (const NamedDecl *D = dyn_cast<NamedDecl>(DC))
     Visit(D);
+  else if (isa<LinkageSpecDecl>(DC)) // Linkage specs are transparent in USRs.
+    VisitDeclContext(DC->getParent());
 }
 
 void USRGenerator::VisitFieldDecl(const FieldDecl *D) {

Added: cfe/trunk/test/Index/USR/linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/linkage.cpp?rev=324093&view=auto
==============================================================================
--- cfe/trunk/test/Index/USR/linkage.cpp (added)
+++ cfe/trunk/test/Index/USR/linkage.cpp Fri Feb  2 06:13:37 2018
@@ -0,0 +1,7 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Linkage decls are skipped in USRs for enclosed items.
+// Linkage decls themselves don't have USRs (no lines between ns and X).
+// CHECK: {{[0-9]+}}:11 | namespace/C++ | ns | c:@N at ns |
+// CHECK-NEXT: {{[0-9]+}}:33 | variable/C | X | c:@N at ns@X |
+namespace ns { extern "C" { int X; } }




More information about the cfe-commits mailing list