From: Sam McCall Date: Fri, 2 Feb 2018 14:13:37 +0000 (+0000) Subject: [Index] fix USR generation for namespace{extern{X}} X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d84cfa2cd0b45ec41c08ffb9ae3ba56904a4a25;p=clang [Index] fix USR generation for namespace{extern{X}} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324093 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index 3a06554b25..ee1c950eb6 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -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::ShouldGenerateLocation(const NamedDecl *D) { void USRGenerator::VisitDeclContext(const DeclContext *DC) { if (const NamedDecl *D = dyn_cast(DC)) Visit(D); + else if (isa(DC)) // Linkage specs are transparent in USRs. + VisitDeclContext(DC->getParent()); } void USRGenerator::VisitFieldDecl(const FieldDecl *D) { diff --git a/test/Index/USR/linkage.cpp b/test/Index/USR/linkage.cpp new file mode 100644 index 0000000000..fec80dace1 --- /dev/null +++ b/test/Index/USR/linkage.cpp @@ -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@ns | +// CHECK-NEXT: {{[0-9]+}}:33 | variable/C | X | c:@N@ns@X | +namespace ns { extern "C" { int X; } }