summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeCompletion
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-09-17 21:32:03 +0000
committerDouglas Gregor <dgregor@apple.com>2009-09-17 21:32:03 +0000
commit2436e7116bb1bda26d8b18b4b34a69a6b5d336d3 (patch)
tree1325762c620a4b86a13623e132661522a34b5cc8 /clang/test/CodeCompletion
parentfaacf018a3cc6615a2012348cbe213b2f8a0a880 (diff)
downloadbcm5719-llvm-2436e7116bb1bda26d8b18b4b34a69a6b5d336d3.tar.gz
bcm5719-llvm-2436e7116bb1bda26d8b18b4b34a69a6b5d336d3.zip
Initial implementation of a code-completion interface in Clang. In
essence, code completion is triggered by a magic "code completion" token produced by the lexer [*], which the parser recognizes at certain points in the grammar. The parser then calls into the Action object with the appropriate CodeCompletionXXX action. Sema implements the CodeCompletionXXX callbacks by performing minimal translation, then forwarding them to a CodeCompletionConsumer subclass, which uses the results of semantic analysis to provide code-completion results. At present, only a single, "printing" code completion consumer is available, for regression testing and debugging. However, the design is meant to permit other code-completion consumers. This initial commit contains two code-completion actions: one for member access, e.g., "x." or "p->", and one for nested-name-specifiers, e.g., "std::". More code-completion actions will follow, along with improved gathering of code-completion results for the various contexts. [*] In the current -code-completion-dump testing/debugging mode, the file is truncated at the completion point and EOF is translated into "code completion". llvm-svn: 82166
Diffstat (limited to 'clang/test/CodeCompletion')
-rw-r--r--clang/test/CodeCompletion/member-access.c13
-rw-r--r--clang/test/CodeCompletion/member-access.cpp42
-rw-r--r--clang/test/CodeCompletion/nested-name-specifier.cpp19
3 files changed, 74 insertions, 0 deletions
diff --git a/clang/test/CodeCompletion/member-access.c b/clang/test/CodeCompletion/member-access.c
new file mode 100644
index 00000000000..25b2b9ce22f
--- /dev/null
+++ b/clang/test/CodeCompletion/member-access.c
@@ -0,0 +1,13 @@
+// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
+// RUN: true
+struct Point {
+ float x;
+ float y;
+ float z;
+};
+
+void test(struct Point *p) {
+ // CHECK-CC1: x
+ // CHECK-CC1: y
+ // CHECK-CC1: z
+ p-> \ No newline at end of file
diff --git a/clang/test/CodeCompletion/member-access.cpp b/clang/test/CodeCompletion/member-access.cpp
new file mode 100644
index 00000000000..234a6318707
--- /dev/null
+++ b/clang/test/CodeCompletion/member-access.cpp
@@ -0,0 +1,42 @@
+// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
+// RUN: true
+
+struct Base1 {
+ int member1;
+ float member2;
+};
+
+struct Base2 {
+ int member1;
+ double member3;
+ void memfun1(int);
+};
+
+struct Base3 : Base1, Base2 {
+ void memfun1(float);
+ void memfun1(double);
+ void memfun2(int);
+};
+
+struct Derived : Base3 {
+ int member4;
+ int memfun3(int);
+};
+
+class Proxy {
+public:
+ Derived *operator->() const;
+};
+
+void test(const Proxy &p) {
+ // CHECK-CC1: member4 : 0
+ // CHECK-CC1: memfun3 : 0
+ // CHECK-CC1: memfun1 : 1
+ // CHECK-CC1: memfun1 : 1
+ // CHECK-CC1: memfun2 : 1
+ // CHECK-CC1: member1 : 2
+ // CHECK-CC1: member1 : 2
+ // CHECK-CC1: member2 : 2
+ // CHECK-CC1: member3 : 2
+ // CHECK-CC1: memfun1 : 2 (Hidden)
+ p-> \ No newline at end of file
diff --git a/clang/test/CodeCompletion/nested-name-specifier.cpp b/clang/test/CodeCompletion/nested-name-specifier.cpp
new file mode 100644
index 00000000000..f418164b024
--- /dev/null
+++ b/clang/test/CodeCompletion/nested-name-specifier.cpp
@@ -0,0 +1,19 @@
+// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
+// RUN: true
+
+namespace N {
+ struct A { };
+ namespace M {
+ struct C { };
+ };
+}
+
+namespace N {
+ struct B { };
+}
+
+// CHECK-CC1: A : 0
+// CHECK-CC1: B : 0
+// CHECK-CC1: M : 0
+// CHECK-CC1: template : 0
+N:: \ No newline at end of file
OpenPOWER on IntegriCloud