From 1d8052db5a38b62ba5f3802160dcccd87fa0b5b8 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 3 May 2011 01:33:35 +0000 Subject: [PATCH] Use the canonical decl when generating the locations for USRs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130748 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Index/usrs.cpp | 22 ++++++++++++++++++++++ tools/libclang/CIndexUSRs.cpp | 3 +++ 2 files changed, 25 insertions(+) diff --git a/test/Index/usrs.cpp b/test/Index/usrs.cpp index a43b6893eb..023818c591 100644 --- a/test/Index/usrs.cpp +++ b/test/Index/usrs.cpp @@ -65,6 +65,20 @@ using foo::ClsB; namespace foo_alias3 = foo; +namespace { +class RDar9371763_Foo { +public: + void bar(); +}; +} + +void RDar9371763_Foo::bar() {} + +void rdar9371763() { + RDar9371763_Foo foo; + foo.bar(); +} + // RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s // CHECK: usrs.cpp c:@N@foo Extent=[1:1 - 4:2] // CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8] @@ -122,3 +136,11 @@ namespace foo_alias3 = foo; // CHECK: usrs.cpp c:@NA@foo_alias2 // CHECK-NOT: ClsB // CHECK: usrs.cpp c:@NA@foo_alias3 +// CHECK: usrs.cpp c:@aN Extent=[68:1 - 73:2] +// CHECK: usrs.cpp c:@aN@C@RDar9371763_Foo Extent=[69:1 - 72:2] +// CHECK: usrs.cpp c: Extent=[70:1 - 70:8] +// CHECK: usrs.cpp c:usrs.cpp@1131@aN@C@RDar9371763_Foo@F@bar# Extent=[71:3 - 71:13] +// CHECK: usrs.cpp c:usrs.cpp@1131@aN@C@RDar9371763_Foo@F@bar# Extent=[75:1 - 75:31] +// CHECK: usrs.cpp c:@F@rdar9371763# Extent=[77:1 - 80:2] +// CHECK: usrs.cpp c:usrs.cpp@1204@F@rdar9371763#@foo Extent=[78:3 - 78:22] + diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp index 9917d2ad21..4f1f071c1d 100644 --- a/tools/libclang/CIndexUSRs.cpp +++ b/tools/libclang/CIndexUSRs.cpp @@ -477,6 +477,9 @@ bool USRGenerator::GenLoc(const Decl *D) { return true; } + // Use the location of canonical decl. + D = D->getCanonicalDecl(); + const SourceManager &SM = AU->getSourceManager(); SourceLocation L = D->getLocStart(); if (L.isInvalid()) { -- 2.40.0