]> granicus.if.org Git - clang/commitdiff
Handle redeclarations properly at the index-test tool.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 14 Jul 2009 03:20:31 +0000 (03:20 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 14 Jul 2009 03:20:31 +0000 (03:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75605 91177308-0d34-0410-b5e6-96231b3b80d8

test/Index/multiple-redecls.c [new file with mode: 0644]
tools/index-test/index-test.cpp

diff --git a/test/Index/multiple-redecls.c b/test/Index/multiple-redecls.c
new file mode 100644 (file)
index 0000000..6f1f75b
--- /dev/null
@@ -0,0 +1,12 @@
+// RUN: clang-cc -emit-pch %s -o %t.ast &&
+// RUN: index-test %t.ast -point-at %s:8:4 -print-decls | count 2 &&
+// RUN: index-test %t.ast -point-at %s:8:4 -print-defs | count 1
+
+static void foo(int x);
+
+static void bar(void) {
+  foo(10);
+}
+
+void foo(int x) { 
+}
index 63c86aac464c88c3b0d48e138d80f11e7c91ba24..a188cd103ed8bc951dffcdde07cef8493531af1d 100644 (file)
@@ -134,15 +134,13 @@ static void ProcessDecl(Decl *D) {
   
   case PrintDecls :
     if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
-      while (FD) {
-        ASTLocation(FD).print(OS);
-        FD = FD->getPreviousDeclaration();
-      }
+      for (FunctionDecl::redecl_iterator I = FD->redecls_begin(),
+                                         E = FD->redecls_end(); I != E; ++I)
+        ASTLocation(*I).print(OS);
     } else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
-      while (VD) {
-        ASTLocation(VD).print(OS);
-        VD = VD->getPreviousDeclaration();
-      }
+      for (VarDecl::redecl_iterator I = VD->redecls_begin(),
+                                    E = VD->redecls_end(); I != E; ++I)
+        ASTLocation(*I).print(OS);
     } else
       ASTLocation(D).print(OS);
     break;