Add basic cursor traversal for attributes.  We currently don't have source
ranges for Attr objects, so lookup by cursor location currently doesn't work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96571 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp
index 21f3860..0b08874 100644
--- a/tools/CIndex/CIndex.cpp
+++ b/tools/CIndex/CIndex.cpp
@@ -254,6 +254,7 @@
   bool VisitChildren(CXCursor Parent);
 
   // Declaration visitors
+  bool VisitAttributes(Decl *D);
   bool VisitDeclContext(DeclContext *DC);
   bool VisitTranslationUnitDecl(TranslationUnitDecl *D);
   bool VisitTypedefDecl(TypedefDecl *D);
@@ -436,6 +437,13 @@
 bool CursorVisitor::VisitDeclContext(DeclContext *DC) {
   for (DeclContext::decl_iterator
        I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I) {
+
+    // Attributes currently don't have source ranges.  We only report them
+    // when the client hasn't specified a region of interest.
+    if (!RegionOfInterest.isValid())
+      if (VisitAttributes(*I))
+        return true;
+
     CXCursor Cursor = MakeCXCursor(*I, TU);
 
     if (RegionOfInterest.isValid()) {
@@ -896,6 +904,14 @@
   return VisitExpr(E);
 }
 
+bool CursorVisitor::VisitAttributes(Decl *D) {
+  for (const Attr *A = D->getAttrs(); A; A = A->getNext())
+    if (Visit(MakeCXCursor(A, D, TU)))
+        return true;
+
+  return false;
+}
+
 extern "C" {
 CXIndex clang_createIndex(int excludeDeclarationsFromPCH) {
   CIndexer *CIdxr = new CIndexer();