Implement libclang support for using declarations. Clang actually uses
three different kinds of AST nodes to represent using declarations:
UsingDecl, UnresolvedUsingValueDecl, and
UnresolvedUsingTypenameDecl. These three are collapsed into a single
cursor kind for using declarations, since libclang clients don't need
the distinction.

Several related changes here:
  - Cursor visitation of the three AST nodes for using declarations
  - Proper source-range computation for these AST nodes
  - Using declarations have no USRs, since they don't actually declare
    any entities.

llvm-svn: 112730
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 3c4211e..947b3b2 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -319,6 +319,9 @@
   bool VisitNamespaceDecl(NamespaceDecl *D);
   bool VisitNamespaceAliasDecl(NamespaceAliasDecl *D);
   bool VisitUsingDirectiveDecl(UsingDirectiveDecl *D);
+  bool VisitUsingDecl(UsingDecl *D);
+  bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
+  bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
@@ -902,19 +905,41 @@
 }
 
 bool CursorVisitor::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
-  // FIXME: Visit nested-name-specifier
+  // FIXME: Visit nested-name-specifier.
   
   return Visit(MakeCursorNamespaceRef(D->getAliasedNamespace(), 
                                       D->getTargetNameLoc(), TU));
 }
 
+bool CursorVisitor::VisitUsingDecl(UsingDecl *D) {
+  // FIXME: Visit nested-name-specifier.
+  
+  // FIXME: Provide a multi-reference of some kind for all of the declarations
+  // that the using declaration refers to. We don't have this kind of cursor
+  // yet.
+  
+  return VisitDeclarationNameInfo(D->getNameInfo());
+}
+
 bool CursorVisitor::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
-  // FIXME: Visit nested-name-specifier
+  // FIXME: Visit nested-name-specifier.
 
   return Visit(MakeCursorNamespaceRef(D->getNominatedNamespaceAsWritten(),
                                       D->getIdentLocation(), TU));
 }
 
+bool CursorVisitor::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
+  // FIXME: Visit nested-name-specifier.
+  
+  return VisitDeclarationNameInfo(D->getNameInfo());
+}
+
+bool CursorVisitor::VisitUnresolvedUsingTypenameDecl(
+                                               UnresolvedUsingTypenameDecl *D) {
+  // FIXME: Visit nested-name-specifier.
+  return false;
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
@@ -2268,6 +2293,8 @@
     return createCXString("NamespaceAlias");
   case CXCursor_UsingDirective:
     return createCXString("UsingDirective");
+  case CXCursor_UsingDeclaration:
+    return createCXString("UsingDeclaration");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");