summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-03 02:20:32 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-11-03 02:20:32 +0000
commite9681525649adf23f626641d5e0c2ec08b756927 (patch)
tree1afba30209580790d505120372fa61e337f328e8 /clang/test
parentcb373e3f31b945738d134c3d1cb93ee666996c03 (diff)
downloadbcm5719-llvm-e9681525649adf23f626641d5e0c2ec08b756927.tar.gz
bcm5719-llvm-e9681525649adf23f626641d5e0c2ec08b756927.zip
[libclang] Add infrastructure to be able to only deserialize decls in a file region and
use it for clang_getCursor. llvm-svn: 143605
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Index/targeted-cursor.c52
-rw-r--r--clang/test/Index/targeted-fields.h3
-rw-r--r--clang/test/Index/targeted-nested1.h2
-rw-r--r--clang/test/Index/targeted-preamble.h2
-rw-r--r--clang/test/Index/targeted-top.h24
5 files changed, 83 insertions, 0 deletions
diff --git a/clang/test/Index/targeted-cursor.c b/clang/test/Index/targeted-cursor.c
new file mode 100644
index 00000000000..ec03156c61b
--- /dev/null
+++ b/clang/test/Index/targeted-cursor.c
@@ -0,0 +1,52 @@
+
+#include "targeted-top.h"
+#include "targeted-preamble.h"
+
+int LocalVar1;
+int LocalVar2;
+
+// RUN: c-index-test -write-pch %t.h.pch %S/targeted-top.h
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%s:5:10 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%s:5:10 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=LOCAL-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-top.h:11:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=vector_get_x \
+// RUN: | FileCheck %s -check-prefix=TOP-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-nested1.h:2:16 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=PreambleVar \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=NESTED-CURSOR1
+
+// RUN: env CINDEXTEST_FAILONERROR=1 CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_NO_CACHING=1 \
+// RUN: c-index-test -cursor-at=%S/targeted-preamble.h:2:15 %s -include %t.h \
+// RUN: -Xclang -error-on-deserialized-decl=NestedVar1 \
+// RUN: -Xclang -error-on-deserialized-decl=TopVar \
+// RUN: | FileCheck %s -check-prefix=PREAMBLE-CURSOR1
+
+// LOCAL-CURSOR1: VarDecl=LocalVar1:5:5
+// TOP-CURSOR1: VarDecl=TopVar:11:12
+// NESTED-CURSOR1: VarDecl=NestedVar1:2:12
+// PREAMBLE-CURSOR1: VarDecl=PreambleVar:2:12
diff --git a/clang/test/Index/targeted-fields.h b/clang/test/Index/targeted-fields.h
new file mode 100644
index 00000000000..7da57f3ef27
--- /dev/null
+++ b/clang/test/Index/targeted-fields.h
@@ -0,0 +1,3 @@
+
+ int z;
+ int w;
diff --git a/clang/test/Index/targeted-nested1.h b/clang/test/Index/targeted-nested1.h
new file mode 100644
index 00000000000..d5a019b6985
--- /dev/null
+++ b/clang/test/Index/targeted-nested1.h
@@ -0,0 +1,2 @@
+
+extern int NestedVar1;
diff --git a/clang/test/Index/targeted-preamble.h b/clang/test/Index/targeted-preamble.h
new file mode 100644
index 00000000000..19b953933f1
--- /dev/null
+++ b/clang/test/Index/targeted-preamble.h
@@ -0,0 +1,2 @@
+
+extern int PreambleVar;
diff --git a/clang/test/Index/targeted-top.h b/clang/test/Index/targeted-top.h
new file mode 100644
index 00000000000..0f3c97586e4
--- /dev/null
+++ b/clang/test/Index/targeted-top.h
@@ -0,0 +1,24 @@
+
+#ifndef TARGETED_TOP_H
+#define TARGETED_TOP_H
+
+#include "targeted-nested1.h"
+
+enum {
+ VALUE = 3
+};
+
+extern int TopVar;
+
+typedef struct {
+ int x;
+ int y;
+#include "targeted-fields.h"
+} Vector;
+
+static inline int vector_get_x(Vector v) {
+ int x = v.x;
+ return x;
+}
+
+#endif
OpenPOWER on IntegriCloud