Use a sane encoding for CXCursor_ObjCProtocolRef, using the actual
source locations where the protocols were referenced rather than the
location of some random enclosing declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93637 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CXCursor.cpp b/tools/CIndex/CXCursor.cpp
index d6c3867..01d809a 100644
--- a/tools/CIndex/CXCursor.cpp
+++ b/tools/CIndex/CXCursor.cpp
@@ -90,6 +90,21 @@
                                       reinterpret_cast<uintptr_t>(C.data[1])));
 }
 
+CXCursor cxcursor::MakeCursorObjCProtocolRef(ObjCProtocolDecl *Super, 
+                                             SourceLocation Loc) {
+  void *RawLoc = reinterpret_cast<void *>(Loc.getRawEncoding());
+  CXCursor C = { CXCursor_ObjCProtocolRef, { Super, RawLoc, 0 } };
+  return C;    
+}
+
+std::pair<ObjCProtocolDecl *, SourceLocation> 
+cxcursor::getCursorObjCProtocolRef(CXCursor C) {
+  assert(C.kind == CXCursor_ObjCProtocolRef);
+  return std::make_pair(static_cast<ObjCProtocolDecl *>(C.data[0]),
+           SourceLocation::getFromRawEncoding(
+                                      reinterpret_cast<uintptr_t>(C.data[1])));
+}
+
 Decl *cxcursor::getCursorDecl(CXCursor Cursor) {
   return (Decl *)Cursor.data[0];
 }
@@ -99,7 +114,8 @@
 }
 
 Stmt *cxcursor::getCursorStmt(CXCursor Cursor) {
-  if (Cursor.kind == CXCursor_ObjCSuperClassRef)
+  if (Cursor.kind == CXCursor_ObjCSuperClassRef ||
+      Cursor.kind == CXCursor_ObjCProtocolRef)
     return 0;
 
   return (Stmt *)Cursor.data[1];