[libclang] Make clang_getCursor able to handle locations that point inside macro arguments.

e.g. for:

\define INVOKE(METHOD, CLASS) [CLASS METHOD]

void test2() {
  INVOKE(meth, MyClass);
}

Pointing at 'meth' will give a CXCursor_ObjCMessageExpr and pointing at 'MyClass'
will give a CXCursor_ObjCClassRef.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137796 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Index/get-cursor-macro-args.h b/test/Index/get-cursor-macro-args.h
new file mode 100644
index 0000000..40ec8dc
--- /dev/null
+++ b/test/Index/get-cursor-macro-args.h
@@ -0,0 +1,16 @@
+@interface MyClass
++(void)meth;
+@end
+
+#define MACRO2(x) x
+#define MACRO(x) MACRO2(x)
+
+void test() {
+  MACRO([MyClass meth]);
+}
+
+#define INVOKE(METHOD, CLASS) [CLASS METHOD]
+
+void test2() {
+  INVOKE(meth, MyClass);
+}
diff --git a/test/Index/get-cursor-macro-args.m b/test/Index/get-cursor-macro-args.m
new file mode 100644
index 0000000..4e0ac78
--- /dev/null
+++ b/test/Index/get-cursor-macro-args.m
@@ -0,0 +1,19 @@
+// Test without PCH
+// RUN: c-index-test -cursor-at=%S/get-cursor-macro-args.h:9:12 \
+// RUN:              -cursor-at=%S/get-cursor-macro-args.h:9:21 \
+// RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:12 \
+// RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:20 \
+// RUN:       %s -include get-cursor-macro-args.h | FileCheck %s
+
+// Test with PCH
+// RUN: c-index-test -write-pch %t.pch -x objective-c-header %S/get-cursor-macro-args.h
+// RUN: c-index-test -cursor-at=%S/get-cursor-macro-args.h:9:12 \
+// RUN:              -cursor-at=%S/get-cursor-macro-args.h:9:21 \
+// RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:12 \
+// RUN:              -cursor-at=%S/get-cursor-macro-args.h:15:20 \
+// RUN:       %s -include-pch %t.pch | FileCheck %s
+
+// CHECK:      ObjCClassRef=MyClass:1:12
+// CHECK-NEXT: ObjCMessageExpr=meth:2:1
+// CHECK-NEXT: ObjCMessageExpr=meth:2:1
+// CHECK-NEXT: ObjCClassRef=MyClass:1:12