Visit the nested-name-specifier and explicitly-specified template
arguments of a DeclRefExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112854 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 89aa92c..6367de3 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -369,7 +369,7 @@
 //  bool VisitSwitchCase(SwitchCase *S);
 
   // Expression visitors
-  // FIXME: DeclRefExpr with template arguments, nested-name-specifier
+  bool VisitDeclRefExpr(DeclRefExpr *E);
   // FIXME: MemberExpr with template arguments, nested-name-specifier
   bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
   bool VisitBlockExpr(BlockExpr *B);
@@ -1438,6 +1438,29 @@
   return false;
 }
 
+bool CursorVisitor::VisitDeclRefExpr(DeclRefExpr *E) {
+  // Visit nested-name-specifier, if present.
+  if (NestedNameSpecifier *Qualifier = E->getQualifier())
+    if (VisitNestedNameSpecifier(Qualifier, E->getQualifierRange()))
+      return true;
+  
+  // Visit declaration name.
+  if (VisitDeclarationNameInfo(E->getNameInfo()))
+    return true;
+  
+  // Visit explicitly-specified template arguments.
+  if (E->hasExplicitTemplateArgs()) {
+    ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
+    for (TemplateArgumentLoc *Arg = Args.getTemplateArgs(),
+                          *ArgEnd = Arg + Args.NumTemplateArgs;
+         Arg != ArgEnd; ++Arg)
+      if (VisitTemplateArgumentLoc(*Arg))
+        return true;
+  }
+  
+  return false;
+}
+
 bool CursorVisitor::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
   if (Visit(MakeCXCursor(E->getArg(0), StmtParent, TU)))
     return true;