Replace the -code-completion-dump option with
-code-completion-at=filename:line:column
which performs code completion at the specified location by truncating
the file at that position and enabling code completion. This approach
makes it possible to run multiple tests from a single test file, and
gives a more natural command-line interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82571 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeCompletion/call.cpp b/test/CodeCompletion/call.cpp
index 4faff15..dd90083 100644
--- a/test/CodeCompletion/call.cpp
+++ b/test/CodeCompletion/call.cpp
@@ -1,5 +1,5 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
void f(float x, float y);
void f(int i, int j, int k);
struct X { };
@@ -10,13 +10,20 @@
operator int() const;
};
- void f(Y y);
+ void f(Y y, int);
}
typedef N::Y Y;
void f();
void test() {
- // CHECK-CC1: f : 0 : f(<#struct N::Y y#>)
+ f(Y(), 0, 0);
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CC1 %s &&
+ // CHECK-CC1: f : 0 : f(<#struct N::Y y#>, <#int#>)
// CHECK-NEXT-CC1: f : 0 : f(<#int i#>, <#int j#>, <#int k#>)
// CHECK-NEXT-CC1: f : 0 : f(<#float x#>, <#float y#>)
- f(Y(),
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CC2 %s &&
+ // CHECK-NOT-CC2: f : 0 : f(<#struct N::Y y#>, <#int#>)
+ // CHECK-CC2: f : 0 : f(<#int i#>, <#int j#>, <#int k#>)
+ // CHECK-NEXT-CC2: f : 0 : f(<#float x#>, <#float y#>)
+ // RUN: true
+}
diff --git a/test/CodeCompletion/enum-switch-case-qualified.cpp b/test/CodeCompletion/enum-switch-case-qualified.cpp
index fc1b0ea..468a4f9 100644
--- a/test/CodeCompletion/enum-switch-case-qualified.cpp
+++ b/test/CodeCompletion/enum-switch-case-qualified.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace M {
namespace N {
@@ -23,11 +20,14 @@
void test(enum N::C::Color color) {
switch (color) {
- // CHECK-NEXT-CC1: Blue : 0 : N::C::Blue
- // CHECK-NEXT-CC1: Green : 0 : N::C::Green
- // CHECK-NEXT-CC1: Indigo : 0 : N::C::Indigo
- // CHECK-NEXT-CC1: Orange : 0 : N::C::Orange
- // CHECK-NEXT-CC1: Red : 0 : N::C::Red
- // CHECK-NEXT-CC1: Violet : 0 : N::C::Violet
- // CHECK-NEXT-CC1: Yellow : 0 : N::C::Yellow
- case
+ case
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:23:8 %s -o - | FileCheck -check-prefix=CC1 %s &&
+ // RUN: true
+ // CHECK-NEXT-CC1: Blue : 0 : N::C::Blue
+ // CHECK-NEXT-CC1: Green : 0 : N::C::Green
+ // CHECK-NEXT-CC1: Indigo : 0 : N::C::Indigo
+ // CHECK-NEXT-CC1: Orange : 0 : N::C::Orange
+ // CHECK-NEXT-CC1: Red : 0 : N::C::Red
+ // CHECK-NEXT-CC1: Violet : 0 : N::C::Violet
+ // CHECK-NEXT-CC1: Yellow : 0 : N::C::Yellow
+
diff --git a/test/CodeCompletion/enum-switch-case.c b/test/CodeCompletion/enum-switch-case.c
index 08488f7..255fbbc 100644
--- a/test/CodeCompletion/enum-switch-case.c
+++ b/test/CodeCompletion/enum-switch-case.c
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
enum Color {
Red,
Orange,
@@ -19,9 +16,14 @@
case Yellow:
break;
+ case Green:
+ break;
+
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:19:10 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: Blue : 0
// CHECK-NEXT-CC1: Green : 0
// CHECK-NEXT-CC1: Indigo : 0
// CHECK-NEXT-CC1: Orange : 0
// CHECK-NEXT-CC1: Violet : 0
- case
+ // RUN: true
+
diff --git a/test/CodeCompletion/enum-switch-case.cpp b/test/CodeCompletion/enum-switch-case.cpp
index 49b33c8..15e50fd 100644
--- a/test/CodeCompletion/enum-switch-case.cpp
+++ b/test/CodeCompletion/enum-switch-case.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace N {
enum Color {
Red,
@@ -15,15 +12,18 @@
void test(enum N::Color color) {
switch (color) {
- case N::Red:
- break;
-
- case N::Yellow:
- break;
-
- // CHECK-CC1: Blue : 0 : N::Blue
- // CHECK-NEXT-CC1: Green : 0 : N::Green
- // CHECK-NEXT-CC1: Indigo : 0 : N::Indigo
- // CHECK-NEXT-CC1: Orange : 0 : N::Orange
- // CHECK-NEXT-CC1: Violet : 0 : N::Violet
- case
+ case N::Red:
+ break;
+
+ case N::Yellow:
+ break;
+
+ case
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:21:8 %s -o - | FileCheck -check-prefix=CC1 %s &&
+ // CHECK-CC1: Blue : 0 : N::Blue
+ // CHECK-NEXT-CC1: Green : 0 : N::Green
+ // CHECK-NEXT-CC1: Indigo : 0 : N::Indigo
+ // CHECK-NEXT-CC1: Orange : 0 : N::Orange
+ // CHECK-NEXT-CC1: Violet : 0 : N::Violet
+
+ // RUN: true
diff --git a/test/CodeCompletion/function-templates.cpp b/test/CodeCompletion/function-templates.cpp
index c9a893e..52cba71 100644
--- a/test/CodeCompletion/function-templates.cpp
+++ b/test/CodeCompletion/function-templates.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace std {
template<typename RandomAccessIterator>
void sort(RandomAccessIterator first, RandomAccessIterator last);
@@ -10,7 +7,9 @@
}
void f() {
+ std::
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:8 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: dyn_cast<<#class X#>>(<#Y *Val#>)
// CHECK-CC1: sort(<#RandomAccessIterator first#>, <#RandomAccessIterator last#>)
- std::
+ // RUN: true
diff --git a/test/CodeCompletion/functions.cpp b/test/CodeCompletion/functions.cpp
index f722e9a..f04ef01 100644
--- a/test/CodeCompletion/functions.cpp
+++ b/test/CodeCompletion/functions.cpp
@@ -1,9 +1,9 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
void f(int i, int j = 2, int k = 5);
void f(float x, float y);
void test() {
+ ::
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:5:5 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: f(<#int i#>{#, <#int j#>{#, <#int k#>#}#})
// CHECK-CC1: f(<#float x#>, <#float y#>)
- ::
+ // RUN: true
diff --git a/test/CodeCompletion/member-access.c b/test/CodeCompletion/member-access.c
index 25b2b9c..1e8e563 100644
--- a/test/CodeCompletion/member-access.c
+++ b/test/CodeCompletion/member-access.c
@@ -1,5 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
struct Point {
float x;
float y;
@@ -7,7 +5,9 @@
};
void test(struct Point *p) {
+ p->
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:8:6 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: x
// CHECK-CC1: y
// CHECK-CC1: z
- p->
\ No newline at end of file
+ // RUN: true
diff --git a/test/CodeCompletion/member-access.cpp b/test/CodeCompletion/member-access.cpp
index c2dfee4..cbd19db 100644
--- a/test/CodeCompletion/member-access.cpp
+++ b/test/CodeCompletion/member-access.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
struct Base1 {
int member1;
float member2;
@@ -29,6 +26,8 @@
};
void test(const Proxy &p) {
+ p->
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:29:6 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: member4 : 0
// CHECK-CC1: memfun3 : 0
// CHECK-CC1: memfun1 : 1
@@ -39,4 +38,5 @@
// CHECK-CC1: member2 : 2
// CHECK-CC1: member3 : 2
// CHECK-CC1: memfun1 : 2 (Hidden) : Base2::memfun1(<#int#>)
- p->
\ No newline at end of file
+ // RUN: true
+
diff --git a/test/CodeCompletion/namespace-alias.cpp b/test/CodeCompletion/namespace-alias.cpp
index 8d70c45..cae3d56 100644
--- a/test/CodeCompletion/namespace-alias.cpp
+++ b/test/CodeCompletion/namespace-alias.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace N4 {
namespace N3 { }
}
@@ -13,10 +10,12 @@
namespace I5 { }
namespace I1 { }
+ namespace New =
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:13:18 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: I1 : 1
// CHECK-CC1: I4 : 1
// CHECK-CC1: I5 : 1
// CHECK-CC1: N2 : 2
// CHECK-NEXT-CC1: N4 : 2
- namespace New =
-
+ // RUN: true
+
\ No newline at end of file
diff --git a/test/CodeCompletion/namespace.cpp b/test/CodeCompletion/namespace.cpp
index db84124..5563698 100644
--- a/test/CodeCompletion/namespace.cpp
+++ b/test/CodeCompletion/namespace.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace N3 {
}
@@ -10,6 +7,9 @@
namespace I5 { }
namespace I1 { }
+ namespace
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:12 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: I1 : 0
// CHECK-NEXT-CC1: I5 : 0
- namespace
+ // RUN: true
+
diff --git a/test/CodeCompletion/nested-name-specifier.cpp b/test/CodeCompletion/nested-name-specifier.cpp
index 4d6a75f..0cc5a19 100644
--- a/test/CodeCompletion/nested-name-specifier.cpp
+++ b/test/CodeCompletion/nested-name-specifier.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace N {
struct A { };
namespace M {
@@ -12,7 +9,10 @@
struct B { };
}
+N::
+// RUN: clang-cc -fsyntax-only -code-completion-at=%s:12:4 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: A : 0
// CHECK-CC1: B : 0
// CHECK-CC1: M : 0
-N::
\ No newline at end of file
+// RUN: true
+
diff --git a/test/CodeCompletion/operator.cpp b/test/CodeCompletion/operator.cpp
index 8089405..72a3f6b 100644
--- a/test/CodeCompletion/operator.cpp
+++ b/test/CodeCompletion/operator.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
class T { };
typedef int Integer;
@@ -10,10 +7,12 @@
void f() {
typedef float Float;
+ operator
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:11 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: Float : 0
// CHECK-CC1: + : 0
// CHECK-CC1: short : 0
// CHECK-CC1: Integer : 2
// CHECK-CC1: T : 2
// CHECK-CC1: N : 5
- operator
+ // RUN: true
diff --git a/test/CodeCompletion/ordinary-name.c b/test/CodeCompletion/ordinary-name.c
index a532409..caba130 100644
--- a/test/CodeCompletion/ordinary-name.c
+++ b/test/CodeCompletion/ordinary-name.c
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
struct X { int x; };
typedef struct X TYPEDEF;
@@ -10,3 +7,5 @@
// CHECK-CC1: y : 0
// CHECK-NEXT-CC1: TYPEDEF : 2
// CHECK-NEXT-CC1: foo : 2
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:6:9 %s -o - | FileCheck -check-prefix=CC1 %s &&
+ // RUN: true
diff --git a/test/CodeCompletion/tag.c b/test/CodeCompletion/tag.c
index 35ddda2..e7250f5 100644
--- a/test/CodeCompletion/tag.c
+++ b/test/CodeCompletion/tag.c
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
enum X { x };
enum Y { y };
struct Z { };
@@ -9,6 +6,8 @@
void test() {
enum X { x };
+ enum
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:9:7 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: X : 0
// CHECK-CC1: Y : 2
- enum
+ // RUN: true
diff --git a/test/CodeCompletion/tag.cpp b/test/CodeCompletion/tag.cpp
index d8f6f2f..201aec4 100644
--- a/test/CodeCompletion/tag.cpp
+++ b/test/CodeCompletion/tag.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
class X { };
struct Y { };
@@ -17,6 +14,8 @@
class Y;
void test() {
+ class
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:17:10 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: Y : 2
// CHECK-CC1: Z : 2
// CHECK-CC1: A : 3
@@ -24,4 +23,4 @@
// CHECK-CC1: Y : 3
// CHECK-CC1: M : 6
// CHECK-CC1: N : 6
- class
+ // RUN: true
diff --git a/test/CodeCompletion/templates.cpp b/test/CodeCompletion/templates.cpp
index f775141..22cca65 100644
--- a/test/CodeCompletion/templates.cpp
+++ b/test/CodeCompletion/templates.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace std {
template<typename T>
class allocator;
@@ -10,8 +7,11 @@
}
void f() {
+ std::
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:10:8 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: allocator<<#typename T#>>
// CHECK-CC1: vector<<#typename T#>{#, <#typename Alloc#>#}>
- std::
-
+ // RUN: true
+
+
diff --git a/test/CodeCompletion/truncation.c b/test/CodeCompletion/truncation.c
new file mode 100644
index 0000000..b64b066
--- /dev/null
+++ b/test/CodeCompletion/truncation.c
@@ -0,0 +1,12 @@
+#include "truncation.c.h"
+
+struct
+
+// RUN: clang-cc -fsyntax-only -code-completion-at=%s.h:4:8 -o - %s | FileCheck -check-prefix=CC1 %s &&
+// CHECK-CC1: X : 1
+// CHECK-NEXT-CC1: Y : 1
+// RUN: clang-cc -fsyntax-only -code-completion-at=%s:3:8 -o - %s | FileCheck -check-prefix=CC2 %s &&
+// CHECK-CC2: X : 1
+// CHECK-CC2: Xa : 1
+// CHECK-CC2: Y : 1
+// RUN: true
diff --git a/test/CodeCompletion/truncation.c.h b/test/CodeCompletion/truncation.c.h
new file mode 100644
index 0000000..a5ebbac
--- /dev/null
+++ b/test/CodeCompletion/truncation.c.h
@@ -0,0 +1,5 @@
+struct X { };
+struct Y { };
+
+struct Xa { };
+
diff --git a/test/CodeCompletion/using-namespace.cpp b/test/CodeCompletion/using-namespace.cpp
index b30b0bc..95bff9b 100644
--- a/test/CodeCompletion/using-namespace.cpp
+++ b/test/CodeCompletion/using-namespace.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace N4 {
namespace N3 { }
}
@@ -14,11 +11,11 @@
namespace I1 { }
void foo() {
+ using namespace
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:14:20 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: I1 : 2
// CHECK-CC1: I4 : 2
// CHECK-CC1: I5 : 2
// CHECK-CC1: N2 : 3
// CHECK-NEXT-CC1: N4 : 3
- using namespace
-
-
+ // RUN: true
diff --git a/test/CodeCompletion/using.cpp b/test/CodeCompletion/using.cpp
index 7bef353..27b85fc 100644
--- a/test/CodeCompletion/using.cpp
+++ b/test/CodeCompletion/using.cpp
@@ -1,6 +1,3 @@
-// RUN: clang-cc -fsyntax-only -code-completion-dump=1 %s -o - | FileCheck -check-prefix=CC1 %s &&
-// RUN: true
-
namespace N4 {
namespace N3 { }
}
@@ -16,12 +13,13 @@
void foo() {
int N3;
+ using
+ // RUN: clang-cc -fsyntax-only -code-completion-at=%s:16:10 %s -o - | FileCheck -check-prefix=CC1 %s &&
// CHECK-CC1: I1 : 2
// CHECK-CC1: I4 : 2
// CHECK-CC1: I5 : 2
// CHECK-CC1: N2 : 3
// CHECK-CC1: N3 : 3
// CHECK-NEXT-CC1: N4 : 3
- using
-
+ // RUN: true