]> granicus.if.org Git - clang/commitdiff
Fix CIndex crash on invalid code reported in <rdar://problem/7833619>.
authorTed Kremenek <kremenek@apple.com>
Wed, 7 Apr 2010 00:27:13 +0000 (00:27 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 7 Apr 2010 00:27:13 +0000 (00:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100589 91177308-0d34-0410-b5e6-96231b3b80d8

test/Index/invalid-code-rdar_7833619.m [new file with mode: 0644]
tools/CIndex/CIndex.cpp

diff --git a/test/Index/invalid-code-rdar_7833619.m b/test/Index/invalid-code-rdar_7833619.m
new file mode 100644 (file)
index 0000000..0034539
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: c-index-test -test-load-source all %s
+// All we care about in this test is that it doesn't crash.
+typedef r7833619_a (*r7833619_b)(r7833619_c *r7833619_d, r7833619_c *r7833619_e);
+
index 01130e22773ddb6790ee198233f9b446b88286b5..7a8c78eceae40beae9ee3af15b48ccb37a936650 100644 (file)
@@ -814,8 +814,9 @@ bool CursorVisitor::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
     return true;
 
   for (unsigned I = 0, N = TL.getNumArgs(); I != N; ++I)
-    if (Visit(MakeCXCursor(TL.getArg(I), TU)))
-      return true;
+    if (Decl *D = TL.getArg(I))
+      if (Visit(MakeCXCursor(D, TU)))
+        return true;
 
   return false;
 }