diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2018-02-02 14:13:37 +0000 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2018-02-02 14:13:37 +0000 |
| commit | 2e50ae6bf28b597753ed2ce0785b8aceaa46d9e0 (patch) | |
| tree | 0507ed4c3dbe320323d756ce7505f09dd4ac5c78 | |
| parent | ab68bbe515590866bd2492cb82e47bf5e93b8235 (diff) | |
| download | bcm5719-llvm-2e50ae6bf28b597753ed2ce0785b8aceaa46d9e0.tar.gz bcm5719-llvm-2e50ae6bf28b597753ed2ce0785b8aceaa46d9e0.zip | |
[Index] fix USR generation for namespace{extern{X}}
llvm-svn: 324093
| -rw-r--r-- | clang/lib/Index/USRGeneration.cpp | 4 | ||||
| -rw-r--r-- | clang/test/Index/USR/linkage.cpp | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp index 3a06554b256..ee1c950eb69 100644 --- a/clang/lib/Index/USRGeneration.cpp +++ b/clang/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<NamedDecl>(DC)) Visit(D); + else if (isa<LinkageSpecDecl>(DC)) // Linkage specs are transparent in USRs. + VisitDeclContext(DC->getParent()); } void USRGenerator::VisitFieldDecl(const FieldDecl *D) { diff --git a/clang/test/Index/USR/linkage.cpp b/clang/test/Index/USR/linkage.cpp new file mode 100644 index 00000000000..fec80dace16 --- /dev/null +++ b/clang/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; } } |

