getLocationFromCursor: If a cursor is a reference and has a referringDecl, using the referringDecl for the location.

llvm-svn: 93520
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp
index 86e0ddc..f24a742 100644
--- a/clang/tools/CIndex/CIndex.cpp
+++ b/clang/tools/CIndex/CIndex.cpp
@@ -409,6 +409,10 @@
                                             SourceManager &SourceMgr,
                                             NamedDecl *ND) {
   if (clang_isReference(C.kind)) {
+    
+    if (Decl *D = static_cast<Decl*>(C.referringDecl))
+      return D->getLocation();
+    
     switch (C.kind) {
     case CXCursor_ObjCClassRef: {
       if (isa<ObjCInterfaceDecl>(ND)) {