[libclang] Fix crash when code-completing a macro invocation that
reached EOF and did not expand the argument into the source context.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170980 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Index/complete-macro-args.c b/test/Index/complete-macro-args.c
index 62a42ff..0b4dd20 100644
--- a/test/Index/complete-macro-args.c
+++ b/test/Index/complete-macro-args.c
@@ -14,11 +14,25 @@
 
 #define MACRO3(x,y,z) x;y;z
 
-void test(struct Point *p) {
+void test2(struct Point *p) {
   MACRO3(p->x);
   MACRO3(p->x
 }
 
+#define VGM(...) 0
+#define VGM2(...) __VA_ARGS__
+
+// These need to be last, to test proper handling of EOF.
+#ifdef EOF_TEST1
+void test3(struct Point *p) {
+  VGM(1,2, p->x
+
+#elif EOF_TEST2
+void test3(struct Point *p) {
+  VGM2(VGM(1,2, p->x
+
+#endif
+
 // RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:12:12 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:18:13 %s | FileCheck %s
@@ -29,3 +43,10 @@
 // CHECK-NEXT: Completion contexts:
 // CHECK-NEXT: Arrow member access
 // CHECK-NEXT: Container Kind: StructDecl
+
+// With these, code-completion is unknown because the macro argument (and the
+// completion point) is not expanded by the macro definition.
+// RUN: c-index-test -code-completion-at=%s:28:15 %s -DEOF_TEST1 | FileCheck %s -check-prefix=CHECK-EOF
+// RUN: c-index-test -code-completion-at=%s:32:20 %s -DEOF_TEST2 | FileCheck %s -check-prefix=CHECK-EOF
+// CHECK-EOF: Completion contexts:
+// CHECK-EOF: Unknown