diff options
Diffstat (limited to 'test/Index')
50 files changed, 1598 insertions, 167 deletions
diff --git a/test/Index/Inputs/crash-recovery-code-complete-remap.c b/test/Index/Inputs/crash-recovery-code-complete-remap.c new file mode 100644 index 0000000..50a8658 --- /dev/null +++ b/test/Index/Inputs/crash-recovery-code-complete-remap.c @@ -0,0 +1,12 @@ +// RUN: echo env CINDEXTEST_EDITING=1 \ +// RUN: not c-index-test -test-load-source-reparse 1 local \ +// RUN: -remap-file="%s;%S/Inputs/crash-recovery-code-complete-remap.c" \ +// RUN: %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s +// CHECK-CODE-COMPLETE-CRASH: Unable to reparse translation unit +// +// XFAIL: win32 + +#warning parsing original file + +#pragma clang __debug crash diff --git a/test/Index/Inputs/crash-recovery-reparse-remap.c b/test/Index/Inputs/crash-recovery-reparse-remap.c new file mode 100644 index 0000000..0357dbe --- /dev/null +++ b/test/Index/Inputs/crash-recovery-reparse-remap.c @@ -0,0 +1,11 @@ + +#warning parsing remapped file + + + +int x; + +#pragma clang __debug crash + +int x; + diff --git a/test/Index/Inputs/preamble-reparse-1.c b/test/Index/Inputs/preamble-reparse-1.c new file mode 100644 index 0000000..139597f --- /dev/null +++ b/test/Index/Inputs/preamble-reparse-1.c @@ -0,0 +1,2 @@ + + diff --git a/test/Index/Inputs/preamble-reparse-2.c b/test/Index/Inputs/preamble-reparse-2.c new file mode 100644 index 0000000..6d1a0d4 --- /dev/null +++ b/test/Index/Inputs/preamble-reparse-2.c @@ -0,0 +1 @@ +int x; diff --git a/test/Index/Inputs/preamble.h b/test/Index/Inputs/preamble.h new file mode 100644 index 0000000..b59c234 --- /dev/null +++ b/test/Index/Inputs/preamble.h @@ -0,0 +1,6 @@ +inline int bar(int i) { + int *ptr = 0; + float *ptr1; + ptr = ptr1; + return 0; +} diff --git a/test/Index/Inputs/prefix.h b/test/Index/Inputs/prefix.h new file mode 100644 index 0000000..82ba2da3 --- /dev/null +++ b/test/Index/Inputs/prefix.h @@ -0,0 +1,4 @@ +#ifndef PREFIX_H +#define PREFIX_H +int foo(int); +#endif diff --git a/test/Index/TestClassDecl.m b/test/Index/TestClassDecl.m index b55c862..09a7d48 100644 --- a/test/Index/TestClassDecl.m +++ b/test/Index/TestClassDecl.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fblocks -emit-pch -x objective-c %s -o %t.ast +// RUN: c-index-test -write-pch %t.ast -fobjc-nonfragile-abi -fblocks -x objective-c %s // RUN: c-index-test -test-file-scan %t.ast %s | FileCheck -check-prefix=scan %s // RUN: c-index-test -test-load-tu %t.ast local | FileCheck -check-prefix=load %s diff --git a/test/Index/annotate-tokens-pp.c b/test/Index/annotate-tokens-pp.c index 485786e..55ee763 100644 --- a/test/Index/annotate-tokens-pp.c +++ b/test/Index/annotate-tokens-pp.c @@ -7,7 +7,25 @@ int BAR STILL_NOTHING; #include "foo.h" #undef BAR -// RUN: c-index-test -test-annotate-tokens=%s:2:1:9:1 -I%S/Inputs %s | FileCheck %s +#define REVERSE_MACRO(x,y) y + x +#define TWICE_MACRO(y) y + y + +void test_macro_args() { + int z = 1; + int t = 2; + int k = REVERSE_MACRO(t,z); + int j = TWICE_MACRO(k + k); + int w = j + j; +} + +#define fun_with_macro_bodies(x, y) do { if (x) y } while (0) + +void test() { + int x = 10; + fun_with_macro_bodies(x, { int z = x; ++z; }); +} + +// RUN: c-index-test -test-annotate-tokens=%s:2:1:26:1 -I%S/Inputs %s | FileCheck %s // CHECK: Punctuation: "#" [2:1 - 2:2] preprocessing directive= // CHECK: Identifier: "define" [2:2 - 2:8] preprocessing directive= // CHECK: Identifier: "STILL_NOTHING" [2:9 - 2:22] macro definition=STILL_NOTHING @@ -56,3 +74,114 @@ int BAR STILL_NOTHING; // CHECK: Punctuation: "#" [8:1 - 8:2] preprocessing directive= // CHECK: Identifier: "undef" [8:2 - 8:7] preprocessing directive= // CHECK: Identifier: "BAR" [8:8 - 8:11] preprocessing directive= +// CHECK: Punctuation: "#" [10:1 - 10:2] preprocessing directive= +// CHECK: Identifier: "define" [10:2 - 10:8] preprocessing directive= +// CHECK: Identifier: "REVERSE_MACRO" [10:9 - 10:22] macro definition=REVERSE_MACRO +// CHECK: Punctuation: "(" [10:22 - 10:23] preprocessing directive= +// CHECK: Identifier: "x" [10:23 - 10:24] preprocessing directive= +// CHECK: Punctuation: "," [10:24 - 10:25] preprocessing directive= +// CHECK: Identifier: "y" [10:25 - 10:26] preprocessing directive= +// CHECK: Punctuation: ")" [10:26 - 10:27] preprocessing directive= +// CHECK: Identifier: "y" [10:28 - 10:29] preprocessing directive= +// CHECK: Punctuation: "+" [10:30 - 10:31] preprocessing directive= +// CHECK: Identifier: "x" [10:32 - 10:33] preprocessing directive= +// CHECK: Punctuation: "#" [11:1 - 11:2] preprocessing directive= +// CHECK: Identifier: "define" [11:2 - 11:8] preprocessing directive= +// CHECK: Identifier: "TWICE_MACRO" [11:9 - 11:20] macro definition=TWICE_MACRO +// CHECK: Punctuation: "(" [11:20 - 11:21] preprocessing directive= +// CHECK: Identifier: "y" [11:21 - 11:22] preprocessing directive= +// CHECK: Punctuation: ")" [11:22 - 11:23] preprocessing directive= +// CHECK: Identifier: "y" [11:24 - 11:25] preprocessing directive= +// CHECK: Punctuation: "+" [11:26 - 11:27] preprocessing directive= +// CHECK: Identifier: "y" [11:28 - 11:29] preprocessing directive= +// CHECK: Keyword: "void" [13:1 - 13:5] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Identifier: "test_macro_args" [13:6 - 13:21] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Punctuation: "(" [13:21 - 13:22] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Punctuation: ")" [13:22 - 13:23] FunctionDecl=test_macro_args:13:6 (Definition) +// CHECK: Punctuation: "{" [13:24 - 13:25] UnexposedStmt= +// CHECK: Keyword: "int" [14:3 - 14:6] VarDecl=z:14:7 (Definition) +// CHECK: Identifier: "z" [14:7 - 14:8] VarDecl=z:14:7 (Definition) +// CHECK: Punctuation: "=" [14:9 - 14:10] VarDecl=z:14:7 (Definition) +// CHECK: Literal: "1" [14:11 - 14:12] UnexposedExpr= +// CHECK: Punctuation: ";" [14:12 - 14:13] UnexposedStmt= +// CHECK: Keyword: "int" [15:3 - 15:6] VarDecl=t:15:7 (Definition) +// CHECK: Identifier: "t" [15:7 - 15:8] VarDecl=t:15:7 (Definition) +// CHECK: Punctuation: "=" [15:9 - 15:10] VarDecl=t:15:7 (Definition) +// CHECK: Literal: "2" [15:11 - 15:12] UnexposedExpr= +// CHECK: Punctuation: ";" [15:12 - 15:13] UnexposedStmt= +// CHECK: Keyword: "int" [16:3 - 16:6] VarDecl=k:16:7 (Definition) +// CHECK: Identifier: "k" [16:7 - 16:8] VarDecl=k:16:7 (Definition) +// CHECK: Punctuation: "=" [16:9 - 16:10] VarDecl=k:16:7 (Definition) +// CHECK: Identifier: "REVERSE_MACRO" [16:11 - 16:24] macro instantiation=REVERSE_MACRO:10:9 +// CHECK: Punctuation: "(" [16:24 - 16:25] UnexposedStmt= +// CHECK: Identifier: "t" [16:25 - 16:26] DeclRefExpr=t:15:7 +// CHECK: Punctuation: "," [16:26 - 16:27] UnexposedStmt= +// CHECK: Identifier: "z" [16:27 - 16:28] DeclRefExpr=z:14:7 +// CHECK: Punctuation: ")" [16:28 - 16:29] UnexposedStmt= +// CHECK: Punctuation: ";" [16:29 - 16:30] UnexposedStmt= +// CHECK: Keyword: "int" [17:3 - 17:6] VarDecl=j:17:7 (Definition) +// CHECK: Identifier: "j" [17:7 - 17:8] VarDecl=j:17:7 (Definition) +// CHECK: Punctuation: "=" [17:9 - 17:10] VarDecl=j:17:7 (Definition) +// CHECK: Identifier: "TWICE_MACRO" [17:11 - 17:22] macro instantiation=TWICE_MACRO:11:9 +// CHECK: Punctuation: "(" [17:22 - 17:23] UnexposedStmt= +// CHECK: Identifier: "k" [17:23 - 17:24] DeclRefExpr=k:16:7 +// CHECK: Punctuation: "+" [17:25 - 17:26] UnexposedStmt= +// CHECK: Identifier: "k" [17:27 - 17:28] DeclRefExpr=k:16:7 +// CHECK: Punctuation: ")" [17:28 - 17:29] UnexposedStmt= +// CHECK: Punctuation: ";" [17:29 - 17:30] UnexposedStmt= +// CHECK: Keyword: "int" [18:3 - 18:6] VarDecl=w:18:7 (Definition) +// CHECK: Identifier: "w" [18:7 - 18:8] VarDecl=w:18:7 (Definition) +// CHECK: Punctuation: "=" [18:9 - 18:10] VarDecl=w:18:7 (Definition) +// CHECK: Identifier: "j" [18:11 - 18:12] DeclRefExpr=j:17:7 +// CHECK: Punctuation: "+" [18:13 - 18:14] UnexposedExpr= +// CHECK: Identifier: "j" [18:15 - 18:16] DeclRefExpr=j:17:7 +// CHECK: Punctuation: ";" [18:16 - 18:17] UnexposedStmt= +// CHECK: Punctuation: "}" [19:1 - 19:2] UnexposedStmt= +// CHECK: Punctuation: "#" [21:1 - 21:2] preprocessing directive= +// CHECK: Identifier: "define" [21:2 - 21:8] preprocessing directive= +// CHECK: Identifier: "fun_with_macro_bodies" [21:9 - 21:30] macro definition=fun_with_macro_bodies +// CHECK: Punctuation: "(" [21:30 - 21:31] preprocessing directive= +// CHECK: Identifier: "x" [21:31 - 21:32] preprocessing directive= +// CHECK: Punctuation: "," [21:32 - 21:33] preprocessing directive= +// CHECK: Identifier: "y" [21:34 - 21:35] preprocessing directive= +// CHECK: Punctuation: ")" [21:35 - 21:36] preprocessing directive= +// CHECK: Keyword: "do" [21:37 - 21:39] preprocessing directive= +// CHECK: Punctuation: "{" [21:40 - 21:41] preprocessing directive= +// CHECK: Keyword: "if" [21:42 - 21:44] preprocessing directive= +// CHECK: Punctuation: "(" [21:45 - 21:46] preprocessing directive= +// CHECK: Identifier: "x" [21:46 - 21:47] preprocessing directive= +// CHECK: Punctuation: ")" [21:47 - 21:48] preprocessing directive= +// CHECK: Identifier: "y" [21:49 - 21:50] preprocessing directive= +// CHECK: Punctuation: "}" [21:51 - 21:52] preprocessing directive= +// CHECK: Keyword: "while" [21:53 - 21:58] preprocessing directive= +// CHECK: Punctuation: "(" [21:59 - 21:60] preprocessing directive= +// CHECK: Literal: "0" [21:60 - 21:61] preprocessing directive= +// CHECK: Punctuation: ")" [21:61 - 21:62] preprocessing directive= +// CHECK: Keyword: "void" [23:1 - 23:5] FunctionDecl=test:23:6 (Definition) +// CHECK: Identifier: "test" [23:6 - 23:10] FunctionDecl=test:23:6 (Definition) +// CHECK: Punctuation: "(" [23:10 - 23:11] FunctionDecl=test:23:6 (Definition) +// CHECK: Punctuation: ")" [23:11 - 23:12] FunctionDecl=test:23:6 (Definition) +// CHECK: Punctuation: "{" [23:13 - 23:14] UnexposedStmt= +// CHECK: Keyword: "int" [24:3 - 24:6] VarDecl=x:24:7 (Definition) +// CHECK: Identifier: "x" [24:7 - 24:8] VarDecl=x:24:7 (Definition) +// CHECK: Punctuation: "=" [24:9 - 24:10] VarDecl=x:24:7 (Definition) +// CHECK: Literal: "10" [24:11 - 24:13] UnexposedExpr= +// CHECK: Punctuation: ";" [24:13 - 24:14] UnexposedStmt= +// CHECK: Identifier: "fun_with_macro_bodies" [25:3 - 25:24] macro instantiation=fun_with_macro_bodies:21:9 +// CHECK: Punctuation: "(" [25:24 - 25:25] UnexposedStmt= +// CHECK: Identifier: "x" [25:25 - 25:26] DeclRefExpr=x:24:7 +// CHECK: Punctuation: "," [25:26 - 25:27] UnexposedStmt= +// CHECK: Punctuation: "{" [25:28 - 25:29] UnexposedStmt= +// CHECK: Keyword: "int" [25:30 - 25:33] UnexposedStmt= +// CHECK: Identifier: "z" [25:34 - 25:35] VarDecl=z:25:3 (Definition) +// CHECK: Punctuation: "=" [25:36 - 25:37] UnexposedStmt= +// CHECK: Identifier: "x" [25:38 - 25:39] DeclRefExpr=x:24:7 +// CHECK: Punctuation: ";" [25:39 - 25:40] UnexposedStmt= +// CHECK: Punctuation: "++" [25:41 - 25:43] UnexposedExpr= +// CHECK: Identifier: "z" [25:43 - 25:44] DeclRefExpr=z:25:3 +// CHECK: Punctuation: ";" [25:44 - 25:45] UnexposedStmt= +// CHECK: Punctuation: "}" [25:46 - 25:47] UnexposedStmt= +// CHECK: Punctuation: ")" [25:47 - 25:48] UnexposedStmt= +// CHECK: Punctuation: ";" [25:48 - 25:49] UnexposedStmt= +// CHECK: Punctuation: "}" [26:1 - 26:2] UnexposedStmt= + diff --git a/test/Index/annotate-tokens.c b/test/Index/annotate-tokens.c index 41f182d..e251596 100644 --- a/test/Index/annotate-tokens.c +++ b/test/Index/annotate-tokens.c @@ -9,7 +9,14 @@ void f(void *ptr) { const char * hello = "Hello"; } -// RUN: c-index-test -test-annotate-tokens=%s:4:1:9:32 %s | FileCheck %s +typedef int Int; +void g(int i, ...) { + __builtin_va_list va; + (void)__builtin_va_arg(va, Int); + (void)__builtin_types_compatible_p(Int, Int); +} + +// RUN: c-index-test -test-annotate-tokens=%s:4:1:17:1 %s | FileCheck %s // CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13 // CHECK: Punctuation: "*" [4:4 - 4:5] VarDecl=t_ptr:4:6 (Definition) // CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition) @@ -61,5 +68,11 @@ void f(void *ptr) { // CHECK: Literal: ""Hello"" [9:24 - 9:31] UnexposedExpr= // CHECK: Punctuation: ";" [9:31 - 9:32] UnexposedStmt= // CHECK: Punctuation: "}" [10:1 - 10:2] UnexposedStmt= +// CHECK: Keyword: "__builtin_va_arg" [15:9 - 15:25] UnexposedExpr= +// CHECK: Identifier: "Int" [15:30 - 15:33] TypeRef=Int:12:13 +// CHECK: Keyword: "__builtin_types_compatible_p" [16:9 - 16:37] UnexposedExpr= +// CHECK: Identifier: "Int" [16:38 - 16:41] TypeRef=Int:12:13 +// CHECK: Punctuation: "," [16:41 - 16:42] UnexposedExpr= +// CHECK: Identifier: "Int" [16:43 - 16:46] TypeRef=Int:12:13 // RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s // RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s diff --git a/test/Index/annotate-tokens.cpp b/test/Index/annotate-tokens.cpp new file mode 100644 index 0000000..dca7af2 --- /dev/null +++ b/test/Index/annotate-tokens.cpp @@ -0,0 +1,23 @@ +struct bonk { }; +void test(bonk X) { + X = X; +} + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:5 %s +// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition) +// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition) +// CHECK: Punctuation: ";" [1:16 - 1:17] +// CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition) +// CHECK: Identifier: "test" [2:6 - 2:10] FunctionDecl=test:2:6 (Definition) +// CHECK: Punctuation: "(" [2:10 - 2:11] FunctionDecl=test:2:6 (Definition) +// CHECK: Identifier: "bonk" [2:11 - 2:15] TypeRef=struct bonk:1:8 +// CHECK: Identifier: "X" [2:16 - 2:17] ParmDecl=X:2:16 (Definition) +// CHECK: Punctuation: ")" [2:17 - 2:18] FunctionDecl=test:2:6 (Definition) +// CHECK: Punctuation: "{" [2:19 - 2:20] UnexposedStmt= +// CHECK: Identifier: "X" [3:5 - 3:6] DeclRefExpr=X:2:16 +// CHECK: Punctuation: "=" [3:7 - 3:8] DeclRefExpr=operator=:1:8 +// CHECK: Identifier: "X" [3:9 - 3:10] DeclRefExpr=X:2:16 +// CHECK: Punctuation: ";" [3:10 - 3:11] UnexposedStmt= +// CHECK: Punctuation: "}" [4:1 - 4:2] UnexposedStmt= diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m index c6e746b..336951b 100644 --- a/test/Index/annotate-tokens.m +++ b/test/Index/annotate-tokens.m @@ -56,7 +56,30 @@ extern int ibaction_test(void); @property IBOutlet int * aPropOutlet; @end -// RUN: c-index-test -test-annotate-tokens=%s:1:1:58:1 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s +// From <rdar://problem/7974151>. The first 'foo:' wasn't being annotated as +// being part of the Objective-C message expression since the argument +// was expanded from a macro. + +#define VAL 0 + +@interface R7974151 +- (int) foo:(int)arg; +- (int) method; +@end + +@implementation R7974151 +- (int) foo:(int)arg { + return arg; +} +- (int) method +{ + int local = [self foo:VAL]; + int second = [self foo:0]; + return local; +} +@end + +// RUN: c-index-test -test-annotate-tokens=%s:1:1:80:4 %s -DIBOutlet='__attribute__((iboutlet))' -DIBAction='void)__attribute__((ibaction)' | FileCheck %s // CHECK: Punctuation: "@" [1:1 - 1:2] ObjCInterfaceDecl=Foo:1:12 // CHECK: Keyword: "interface" [1:2 - 1:11] ObjCInterfaceDecl=Foo:1:12 // CHECK: Identifier: "Foo" [1:12 - 1:15] ObjCInterfaceDecl=Foo:1:12 @@ -224,7 +247,7 @@ extern int ibaction_test(void); // CHECK: Keyword: "interface" [51:2 - 51:11] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Identifier: "IBOutletTests" [51:12 - 51:25] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "{" [52:1 - 52:2] ObjCInterfaceDecl=IBOutletTests:51:12 -// CHECK: Identifier: "IBOutlet" [53:5 - 53:13] macro instantiation=IBOutlet:{{[0-9]+}}:{{[0-9]+}} +// CHECK: Identifier: "IBOutlet" [53:5 - 53:13] macro instantiation=IBOutlet // CHECK: Keyword: "char" [53:14 - 53:18] ObjCIvarDecl=anOutlet:53:21 (Definition) // CHECK: Punctuation: "*" [53:19 - 53:20] ObjCIvarDecl=anOutlet:53:21 (Definition) // CHECK: Identifier: "anOutlet" [53:21 - 53:29] ObjCIvarDecl=anOutlet:53:21 (Definition) @@ -243,11 +266,86 @@ extern int ibaction_test(void); // CHECK: Punctuation: ";" [55:34 - 55:35] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "@" [56:1 - 56:2] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Keyword: "property" [56:2 - 56:10] ObjCInterfaceDecl=IBOutletTests:51:12 -// CHECK: Identifier: "IBOutlet" [56:11 - 56:19] macro instantiation=IBOutlet:{{[0-9]+}}:{{[0-9]+}} +// CHECK: Identifier: "IBOutlet" [56:11 - 56:19] macro instantiation=IBOutlet // CHECK: Keyword: "int" [56:20 - 56:23] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "*" [56:24 - 56:25] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Identifier: "aPropOutlet" [56:26 - 56:37] ObjCPropertyDecl=aPropOutlet:56:26 // CHECK: Punctuation: ";" [56:37 - 56:38] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Punctuation: "@" [57:1 - 57:2] ObjCInterfaceDecl=IBOutletTests:51:12 // CHECK: Keyword: "end" [57:2 - 57:5] ObjCInterfaceDecl=IBOutletTests:51:12 - +// CHECK: Punctuation: "#" [63:1 - 63:2] preprocessing directive= +// CHECK: Identifier: "define" [63:2 - 63:8] preprocessing directive= +// CHECK: Identifier: "VAL" [63:9 - 63:12] macro definition=VAL +// CHECK: Literal: "0" [63:13 - 63:14] preprocessing directive= +// CHECK: Punctuation: "@" [65:1 - 65:2] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Keyword: "interface" [65:2 - 65:11] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Identifier: "R7974151" [65:12 - 65:20] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Punctuation: "-" [66:1 - 66:2] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: "(" [66:3 - 66:4] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Keyword: "int" [66:4 - 66:7] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: ")" [66:7 - 66:8] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Identifier: "foo" [66:9 - 66:12] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: ":" [66:12 - 66:13] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: "(" [66:13 - 66:14] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Keyword: "int" [66:14 - 66:17] ParmDecl=arg:66:18 (Definition) +// CHECK: Punctuation: ")" [66:17 - 66:18] ParmDecl=arg:66:18 (Definition) +// CHECK: Identifier: "arg" [66:18 - 66:21] ParmDecl=arg:66:18 (Definition) +// CHECK: Punctuation: ";" [66:21 - 66:22] ObjCInstanceMethodDecl=foo::66:1 +// CHECK: Punctuation: "-" [67:1 - 67:2] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: "(" [67:3 - 67:4] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Keyword: "int" [67:4 - 67:7] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: ")" [67:7 - 67:8] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Identifier: "method" [67:9 - 67:15] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: ";" [67:15 - 67:16] ObjCInstanceMethodDecl=method:67:1 +// CHECK: Punctuation: "@" [68:1 - 68:2] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Keyword: "end" [68:2 - 68:5] ObjCInterfaceDecl=R7974151:65:12 +// CHECK: Punctuation: "@" [70:1 - 70:2] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Keyword: "implementation" [70:2 - 70:16] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Identifier: "R7974151" [70:17 - 70:25] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Punctuation: "-" [71:1 - 71:2] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: "(" [71:3 - 71:4] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Keyword: "int" [71:4 - 71:7] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: ")" [71:7 - 71:8] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Identifier: "foo" [71:9 - 71:12] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: ":" [71:12 - 71:13] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Punctuation: "(" [71:13 - 71:14] ObjCInstanceMethodDecl=foo::71:1 (Definition) +// CHECK: Keyword: "int" [71:14 - 71:17] ParmDecl=arg:71:18 (Definition) +// CHECK: Punctuation: ")" [71:17 - 71:18] ParmDecl=arg:71:18 (Definition) +// CHECK: Identifier: "arg" [71:18 - 71:21] ParmDecl=arg:71:18 (Definition) +// CHECK: Punctuation: "{" [71:22 - 71:23] UnexposedStmt= +// CHECK: Keyword: "return" [72:3 - 72:9] UnexposedStmt= +// CHECK: Identifier: "arg" [72:10 - 72:13] DeclRefExpr=arg:71:18 +// CHECK: Punctuation: ";" [72:13 - 72:14] UnexposedStmt= +// CHECK: Punctuation: "}" [73:1 - 73:2] UnexposedStmt= +// CHECK: Punctuation: "-" [74:1 - 74:2] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Punctuation: "(" [74:3 - 74:4] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Keyword: "int" [74:4 - 74:7] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Punctuation: ")" [74:7 - 74:8] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Identifier: "method" [74:9 - 74:15] ObjCInstanceMethodDecl=method:74:1 (Definition) +// CHECK: Punctuation: "{" [75:1 - 75:2] UnexposedStmt= +// CHECK: Keyword: "int" [76:5 - 76:8] VarDecl=local:76:9 (Definition) +// CHECK: Identifier: "local" [76:9 - 76:14] VarDecl=local:76:9 (Definition) +// CHECK: Punctuation: "=" [76:15 - 76:16] VarDecl=local:76:9 (Definition) +// CHECK: Punctuation: "[" [76:17 - 76:18] ObjCMessageExpr=foo::66:1 +// CHECK: Identifier: "self" [76:18 - 76:22] DeclRefExpr=self:0:0 +// CHECK: Identifier: "foo" [76:23 - 76:26] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ":" [76:26 - 76:27] ObjCMessageExpr=foo::66:1 +// CHECK: Identifier: "VAL" [76:27 - 76:30] macro instantiation=VAL:63:9 +// CHECK: Punctuation: "]" [76:30 - 76:31] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ";" [76:31 - 76:32] UnexposedStmt= +// CHECK: Keyword: "int" [77:5 - 77:8] VarDecl=second:77:9 (Definition) +// CHECK: Identifier: "second" [77:9 - 77:15] VarDecl=second:77:9 (Definition) +// CHECK: Punctuation: "=" [77:16 - 77:17] VarDecl=second:77:9 (Definition) +// CHECK: Punctuation: "[" [77:18 - 77:19] ObjCMessageExpr=foo::66:1 +// CHECK: Identifier: "self" [77:19 - 77:23] DeclRefExpr=self:0:0 +// CHECK: Identifier: "foo" [77:24 - 77:27] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ":" [77:27 - 77:28] ObjCMessageExpr=foo::66:1 +// CHECK: Literal: "0" [77:28 - 77:29] UnexposedExpr= +// CHECK: Punctuation: "]" [77:29 - 77:30] ObjCMessageExpr=foo::66:1 +// CHECK: Punctuation: ";" [77:30 - 77:31] UnexposedStmt= +// CHECK: Keyword: "return" [78:5 - 78:11] UnexposedStmt= +// CHECK: Identifier: "local" [78:12 - 78:17] DeclRefExpr=local:76:9 +// CHECK: Punctuation: ";" [78:17 - 78:18] UnexposedStmt= +// CHECK: Punctuation: "}" [79:1 - 79:2] UnexposedStmt= +// CHECK: Punctuation: "@" [80:1 - 80:2] ObjCImplementationDecl=R7974151:70:1 (Definition) +// CHECK: Keyword: "end" [80:2 - 80:5] diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 4e5eed4..5fe7cd6 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -6,7 +6,7 @@ __attribute__((iboutlet)) id myoutlet; } - (void) __attribute__((ibaction)) myMessage:(id)msg; -- foo; +- foo __attribute__((deprecated)); + fooC; @end @@ -56,7 +56,7 @@ int main (int argc, const char * argv[]) { // Test attribute traversal. #define IBOutlet __attribute__((iboutlet)) -#define IBOutletCollection(ClassName) __attribute__((iboutletcollection)) +#define IBOutletCollection(ClassName) __attribute__((iboutletcollection(ClassName))) #define IBAction void)__attribute__((ibaction) @interface TestAttributes { @@ -78,7 +78,7 @@ struct X0 {}; // CHECK: <invalid loc>:0:0: attribute(ibaction)= // CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53] // CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49] -// CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 Extent=[9:1 - 9:7] +// CHECK: c-index-api-loadTU-test.m:9:1: ObjCInstanceMethodDecl=foo:9:1 (deprecated) Extent=[9:1 - 9:35] // CHECK: c-index-api-loadTU-test.m:10:1: ObjCClassMethodDecl=fooC:10:1 Extent=[10:1 - 10:8] // CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5] // CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21] @@ -143,10 +143,15 @@ struct X0 {}; // CHECK: c-index-api-loadTU-test.m:63:19: ObjCIvarDecl=anOutlet:63:19 (Definition) Extent=[63:19 - 63:27] // CHECK: <invalid loc>:0:0: attribute(iboutlet)= // CHECK: c-index-api-loadTU-test.m:64:29: ObjCIvarDecl=anOutletCollection:64:29 (Definition) Extent=[64:29 - 64:47] -// CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= +// CHECK: <invalid loc>:0:0: attribute(iboutletcollection)= [IBOutletCollection=ObjCObjectPointer] // CHECK: c-index-api-loadTU-test.m:64:26: TypeRef=id:0:0 Extent=[64:26 - 64:28] // CHECK: c-index-api-loadTU-test.m:66:1: ObjCInstanceMethodDecl=actionMethod::66:1 Extent=[66:1 - 66:35] // CHECK: <invalid loc>:0:0: attribute(ibaction)= // CHECK: c-index-api-loadTU-test.m:66:31: ParmDecl=arg:66:31 (Definition) Extent=[66:28 - 66:34] // CHECK: c-index-api-loadTU-test.m:66:28: TypeRef=id:0:0 Extent=[66:28 - 66:30] +// CHECK: c-index-api-loadTU-test.m:69:16: StructDecl=X0:69:16 Extent=[69:9 - 69:18] +// CHECK: c-index-api-loadTU-test.m:69:19: TypedefDecl=X1:69:19 (Definition) Extent=[69:19 - 69:21] +// CHECK: c-index-api-loadTU-test.m:69:16: TypeRef=struct X0:71:8 Extent=[69:16 - 69:18] +// CHECK: c-index-api-loadTU-test.m:70:8: StructDecl=X0:70:8 Extent=[70:1 - 70:10] +// CHECK: c-index-api-loadTU-test.m:71:8: StructDecl=X0:71:8 (Definition) Extent=[71:1 - 71:14] diff --git a/test/Index/cindex-from-source.m b/test/Index/cindex-from-source.m index 86e794d..f226e45 100644 --- a/test/Index/cindex-from-source.m +++ b/test/Index/cindex-from-source.m @@ -7,3 +7,6 @@ // CHECK: cindex-from-source.m:9:1: TypeRef=t0:1:13 Extent=[9:1 - 9:3] struct s0 {}; t0 g0; + +// RUN: c-index-test -test-load-source-reparse 5 local %s -include %t.pfx.h > %t +// RUN: FileCheck %s < %t diff --git a/test/Index/code-completion.cpp b/test/Index/code-completion.cpp index 1d50fd3..7b0c8d7 100644 --- a/test/Index/code-completion.cpp +++ b/test/Index/code-completion.cpp @@ -15,9 +15,9 @@ struct Z : X, Y { double member; operator int() const; }; - +struct W { }; struct Z get_Z(); - +namespace N { } void test_Z() { // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s get_Z().member = 17; @@ -40,28 +40,28 @@ Z::operator int() const { // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member} // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member} // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const} -// CHECK-MEMBER: FunctionDecl:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )} +// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} +// CHECK-MEMBER: CXXConversion:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const} +// CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )} +// CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )} +// CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )} // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1} // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::} // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::} // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )} -// CHECK-MEMBER: FunctionDecl:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} +// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} +// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )} +// CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )} // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )} // CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )} // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s -// CHECK-EXPR: NotImplemented:{TypedText int} (40) -// CHECK-EXPR: NotImplemented:{TypedText long} (40) +// CHECK-EXPR: NotImplemented:{TypedText int} (65) +// CHECK-EXPR: NotImplemented:{TypedText long} (65) // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10) // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5) // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11) -// CHECK-EXPR: FunctionDecl:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22) - +// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22) +// CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75) diff --git a/test/Index/complete-at-exprstmt.m b/test/Index/complete-at-exprstmt.m index 8537098..cccfa26 100644 --- a/test/Index/complete-at-exprstmt.m +++ b/test/Index/complete-at-exprstmt.m @@ -9,6 +9,16 @@ @synchronized (@encode(MyClass)) { } } @end + +@interface A ++ (int)add:(int)x to:(int)y; ++ (int)add:(int)x to:(int)y plus:(int)z; +@end + +void f() { + @selector(add:to:); +} + // RUN: c-index-test -code-completion-at=%s:9:4 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )} // CHECK-CC1: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )} @@ -35,3 +45,11 @@ // CHECK-CC3: ObjCInterfaceDecl:{TypedText MyClass} // CHECK-CC3: TypedefDecl:{TypedText SEL} // CHECK-CC3: NotImplemented:{ResultType MyClass *}{TypedText self} +// RUN: c-index-test -code-completion-at=%s:19:13 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{TypedText add:to:} (30) +// CHECK-CC4: NotImplemented:{TypedText add:to:plus:} (30) +// CHECK-CC4: NotImplemented:{TypedText myMethod:} (30) +// RUN: c-index-test -code-completion-at=%s:19:17 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:} (30) +// CHECK-CC5: NotImplemented:{Informative add:}{TypedText to:plus:} (30) + diff --git a/test/Index/complete-blocks.m b/test/Index/complete-blocks.m new file mode 100644 index 0000000..7233efb --- /dev/null +++ b/test/Index/complete-blocks.m @@ -0,0 +1,24 @@ +// The line and column layout of this test is significant. Run lines +// are at the end. +typedef void (^block_t)(float f, double d); +void f(int (^block)(int x, int y)); +void g(block_t b); + +void test_f() { + +} + +@interface A +- method:(int (^)(int x, int y))b; +- method2:(block_t)b; +@end + +void test_A(A *a) { + [a method:0]; +} +// RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int (^)(int x, int y)}{RightParen )} (45) +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder void (^)(float f, double d)}{RightParen )} (45) +// RUN: c-index-test -code-completion-at=%s:17:6 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method2:}{Placeholder void (^)(float f, double d)} (20) +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType id}{TypedText method:}{Placeholder int (^)(int x, int y)} (20) diff --git a/test/Index/complete-ctor-inits.cpp b/test/Index/complete-ctor-inits.cpp new file mode 100644 index 0000000..f9cc702 --- /dev/null +++ b/test/Index/complete-ctor-inits.cpp @@ -0,0 +1,40 @@ +// The run lines are below, because this test is line- and +// column-number sensitive. + +template<typename T> +struct X { + X(T); +}; + +struct Virt { }; +struct Y : virtual Virt { }; + +struct Z : public X<int>, public Y { + Z(); + + int a, b, c; +}; + +Z::Z() : ::X<int>(0), Virt(), b(), c() { } + +// RUN: c-index-test -code-completion-at=%s:18:10 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC1: NotImplemented:{TypedText X<int>}{LeftParen (}{Placeholder args}{RightParen )} (7) +// CHECK-CC1: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (20) + +// RUN: c-index-test -code-completion-at=%s:18:23 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC2: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (7) + +// RUN: c-index-test -code-completion-at=%s:18:36 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText a}{LeftParen (}{Placeholder args}{RightParen )} (20) +// CHECK-CC3-NOT: NotImplemented:{TypedText b}{LeftParen (}{Placeholder args}{RightParen )} +// CHECK-CC3: NotImplemented:{TypedText c}{LeftParen (}{Placeholder args}{RightParen )} (7) +// CHECK-CC3-NOT: NotImplemented:{TypedText Virt}{LeftParen (}{Placeholder args}{RightParen )} +// CHECK-CC3: NotImplemented:{TypedText Y}{LeftParen (}{Placeholder args}{RightParen )} (20) diff --git a/test/Index/complete-declarators.cpp b/test/Index/complete-declarators.cpp new file mode 100644 index 0000000..8fba4db --- /dev/null +++ b/test/Index/complete-declarators.cpp @@ -0,0 +1,39 @@ +// This test is line- and column-sensitive, so test commands are at the bottom. +namespace N { + struct X { + int f(X); + }; +} + +int g(int a); + +struct Y { }; + +struct Z { + int member; + friend int N::X::f(N::X); +}; + +// RUN: c-index-test -code-completion-at=%s:8:5 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText const} (30) +// CHECK-CC1: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC1: NotImplemented:{TypedText operator} (30) +// CHECK-CC1: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:8:11 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText const} (30) +// CHECK-CC2-NOT: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC2-NOT: NotImplemented:{TypedText operator} (30) +// CHECK-CC2: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:13:7 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText const} (30) +// CHECK-CC3-NOT: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC3: NotImplemented:{TypedText operator} (30) +// CHECK-CC3: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:14:14 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{TypedText const} (30) +// CHECK-CC4: Namespace:{TypedText N}{Text ::} (75) +// CHECK-CC4: NotImplemented:{TypedText operator} (30) +// CHECK-CC4: NotImplemented:{TypedText volatile} (30) +// CHECK-CC4: StructDecl:{TypedText Y} (65) +// CHECK-CC4: StructDecl:{TypedText Z} (20) + diff --git a/test/Index/complete-declarators.m b/test/Index/complete-declarators.m new file mode 100644 index 0000000..3a69282 --- /dev/null +++ b/test/Index/complete-declarators.m @@ -0,0 +1,45 @@ +// This test is line- and column-sensitive, so test commands are at the bottom. +@protocol P +- (int)method:(id)param1; +@end + +@interface A <P> +- (int)method:(id)param1; + +@property int prop1; +@end + +@implementation A +- (int)method:(id)param1 { + int q2; + for(id q in param1) { + int y; + } + id q; + for(q in param1) { + int y; + } +} +@end + +// RUN: c-index-test -code-completion-at=%s:7:19 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1-NOT: NotImplemented:{TypedText extern} (30) +// CHECK-CC1: NotImplemented:{TypedText param1} (30) +// RUN: c-index-test -code-completion-at=%s:9:15 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: c-index-test -code-completion-at=%s:15:10 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: c-index-test -code-completion-at=%s:16:9 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText const} (30) +// CHECK-CC2-NOT: int +// CHECK-CC2: NotImplemented:{TypedText restrict} (30) +// CHECK-CC2: NotImplemented:{TypedText volatile} (30) +// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: ParmDecl:{ResultType id}{TypedText param1} (8) +// CHECK-CC3-NOT: VarDecl:{ResultType int}{TypedText q2} (8) +// CHECK-CC3-NOT: VarDecl:{ResultType id}{TypedText q} (8) +// CHECK-CC3: NotImplemented:{ResultType A *}{TypedText self} (8) +// CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) +// RUN: c-index-test -code-completion-at=%s:15:15 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: ParmDecl:{ResultType id}{TypedText param1} (8) +// CHECK-CC4-NOT: VarDecl:{ResultType int}{TypedText q2} (8) +// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (8) +// CHECK-CC4: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) diff --git a/test/Index/complete-exprs.c b/test/Index/complete-exprs.c index b7bed8c..2a7a1e2 100644 --- a/test/Index/complete-exprs.c +++ b/test/Index/complete-exprs.c @@ -1,27 +1,37 @@ // Note: the run lines follow their respective tests, since line/column // matter in this test. -int f(int); +int f(int) __attribute__((unavailable)); int test(int i, int j, int k, int l) { return i | j | k & l; } -struct X f1 = { 17 }; +struct X __attribute__((deprecated)) f1 = { 17 }; void f2() { f1(17); } const char *str = "Hello, \nWorld"; +void f3(const char*, ...) __attribute__((sentinel(0))); + +#define NULL __null +void f4(const char* str) { + f3(str, NULL); +} // RUN: c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (60) // CHECK-CC1: macro definition:{TypedText __VERSION__} (70) -// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) -// CHECK-CC1-NOT: NotImplemented:{TypedText float} (40) +// CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable) +// CHECK-CC1-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (2) // CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:9 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s // RUN: c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:7:14 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText __VERSION__} (70) // CHECK-CC3: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC3-NOT: NotImplemented:{TypedText float} (40) +// CHECK-CC3-NOT: NotImplemented:{TypedText float} (65) // CHECK-CC3: ParmDecl:{ResultType int}{TypedText j} (8) // CHECK-CC3: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expressio @@ -30,13 +40,14 @@ const char *str = "Hello, \nWorld"; // RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: macro definition:{TypedText __VERSION__} (70) // CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC2: NotImplemented:{TypedText float} (40) +// CHECK-CC2: NotImplemented:{TypedText float} (65) // CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (8) // CHECK-CC2: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (30) // RUN: c-index-test -code-completion-at=%s:11:16 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s // CHECK-CC4: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50) -// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) +// CHECK-CC4: VarDecl:{ResultType struct X}{TypedText f1} (50) (deprecated) -// RUN: c-index-test -code-completion-at=%s:13:28 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: NotImplemented:{TypedText void} (40) -// CHECK-CC5: NotImplemented:{TypedText volatile} (40) +// RUN: c-index-test -code-completion-at=%s:19:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s +// CHECK-CC6: FunctionDecl:{ResultType void}{TypedText f3}{LeftParen (}{Placeholder char const *, ...}{Text , NULL}{RightParen )} (45) +// CHECK-CC6: NotImplemented:{TypedText void} (65) +// CHECK-CC6: NotImplemented:{TypedText volatile} (65) diff --git a/test/Index/complete-hiding.c b/test/Index/complete-hiding.c new file mode 100644 index 0000000..f2e1775 --- /dev/null +++ b/test/Index/complete-hiding.c @@ -0,0 +1,29 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +struct StructA { }; +struct StructB { }; +struct StructC { }; +int ValueA; +int ValueB; + +void f() { + + int ValueA = 0; + int StructA = 0; + struct StructB { }; + + struct StructA sa = { }; +} + +// RUN: c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: VarDecl:{ResultType int}{TypedText StructA} (8) +// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueA} (8) +// CHECK-CC1-NOT: VarDecl:{ResultType int}{TypedText ValueA} (50) +// CHECK-CC1: VarDecl:{ResultType int}{TypedText ValueB} (50) +// RUN: c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: StructDecl:{TypedText StructA} (65) +// CHECK-CC2-NOT: StructDecl:{TypedText StructB} (65) +// CHECK-CC2: StructDecl:{TypedText StructC} (65) +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:16:10 %s | FileCheck -check-prefix=CHECK-CC2 %s diff --git a/test/Index/complete-macros.c b/test/Index/complete-macros.c index 9a898e1..26a63b1 100644 --- a/test/Index/complete-macros.c +++ b/test/Index/complete-macros.c @@ -16,9 +16,12 @@ void f2() { } // RUN: c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:1 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: macro definition:{TypedText FOO}{LeftParen (}{Placeholder Arg1}{Comma , }{Placeholder Arg2}{RightParen )} // RUN: c-index-test -code-completion-at=%s:13:13 %s | FileCheck -check-prefix=CHECK-CC2 %s // RUN: c-index-test -code-completion-at=%s:14:8 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:8 %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: macro definition:{TypedText nil} (30) // RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: macro definition:{TypedText nil} (60) diff --git a/test/Index/complete-memfunc-cvquals.cpp b/test/Index/complete-memfunc-cvquals.cpp new file mode 100644 index 0000000..4e2e820 --- /dev/null +++ b/test/Index/complete-memfunc-cvquals.cpp @@ -0,0 +1,86 @@ +// The run lines are below, because this test is line- and +// column-number sensitive. +struct Foo { + void babble() const volatile; + void bar(); + void baz() const; + void bingo() volatile; + void theend() const volatile; +}; + +template<typename T> +struct smart_ptr { + T *operator->(); + const T* operator->() const; +}; + +void text(Foo f, Foo *fp, const Foo &fc, const Foo *fcp, + smart_ptr<Foo> sf, const smart_ptr<Foo> &sfc, Foo volatile *fvp) { + f.bar(); + fp->bar(); + fc.baz(); + fcp->baz(); + sf->bar(); + sfc->baz(); + fvp->babble(); +} + +void Foo::bar() { + +} + +void Foo::baz() const { + +} + +void Foo::bingo() volatile { + +} + +// Check member access expressions. +// RUN: c-index-test -code-completion-at=%s:19:5 %s | FileCheck -check-prefix=CHECK-NOQUALS %s +// RUN: c-index-test -code-completion-at=%s:20:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s +// RUN: c-index-test -code-completion-at=%s:23:7 %s | FileCheck -check-prefix=CHECK-NOQUALS %s +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20) +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (19) +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (20) +// CHECK-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (20) +// RUN: c-index-test -code-completion-at=%s:21:6 %s | FileCheck -check-prefix=CHECK-CONST %s +// RUN: c-index-test -code-completion-at=%s:22:8 %s | FileCheck -check-prefix=CHECK-CONST %s +// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CONST %s +// CHECK-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20) +// CHECK-CONST-NOT: bar +// CHECK-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (19) +// CHECK-CONST-NOT: bingo +// CHECK-CONST: theend +// RUN: c-index-test -code-completion-at=%s:25:8 %s | FileCheck -check-prefix=CHECK-VOLATILE %s +// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (20) +// CHECK-VOLATILE-NOT: baz +// CHECK-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (19) + +// Check implicit member access expressions. +// RUN: c-index-test -code-completion-at=%s:29:2 %s | FileCheck -check-prefix=CHECK-IMPLICIT-NOQUALS %s +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15) +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{RightParen )} (14) +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (15) +// CHECK-IMPLICIT-NOQUALS: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (15) + +// RUN: c-index-test -code-completion-at=%s:33:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-CONST %s +// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15) +// CHECK-IMPLICIT-CONST-NOT: bar +// CHECK-IMPLICIT-CONST: CXXMethod:{ResultType void}{TypedText baz}{LeftParen (}{RightParen )}{Informative const} (14) +// CHECK-IMPLICIT-CONST-NOT: bingo +// CHECK-IMPLICIT-CONST: theend + +// RUN: c-index-test -code-completion-at=%s:37:1 %s | FileCheck -check-prefix=CHECK-IMPLICIT-VOLATILE %s +// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText babble}{LeftParen (}{RightParen )}{Informative const volatile} (15) +// CHECK-IMPLICIT-VOLATILE-NOT: baz +// CHECK-IMPLICIT-VOLATILE: CXXMethod:{ResultType void}{TypedText bingo}{LeftParen (}{RightParen )}{Informative volatile} (14) + +// RUN: c-index-test -code-completion-at=%s:4:17 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER %s +// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText const} (30) +// CHECK-CVQUAL-AFTER: NotImplemented:{TypedText volatile} (30) + +// RUN: c-index-test -code-completion-at=%s:4:23 %s | FileCheck -check-prefix=CHECK-CVQUAL-AFTER2 %s +// CHECK-CVQUAL-AFTER2-NOT: NotImplemented:{TypedText const} (30) +// CHECK-CVQUAL-AFTER2: NotImplemented:{TypedText volatile} (30) diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m index a30874b..1324ae4 100644 --- a/test/Index/complete-method-decls.m +++ b/test/Index/complete-method-decls.m @@ -52,43 +52,51 @@ - (int)first:(int)x second2:(float)y third:(double)z; @end +@implementation D +- (int)first:(int)x second2:(float)y third:(double)z { } +@end + +@interface Passing +- (oneway void)method:(in id x); +@end + // RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText abc} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} -// CHECK-CC1: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} // RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: NotImplemented:{TypedText abc} -// CHECK-CC2-NEXT: NotImplemented:{TypedText getSelf} -// CHECK-CC2: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} -// CHECK-CC2: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc} +// CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf} +// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} // RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s -// CHECK-CC3: NotImplemented:{TypedText abc} -// CHECK-CC3-NEXT: NotImplemented:{TypedText getSelf} -// CHECK-CC3: NotImplemented:{TypedText init} -// CHECK-CC3: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} -// CHECK-CC3: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc} +// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x} +// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y} // RUN: c-index-test -code-completion-at=%s:33:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText abc} -// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC4: NotImplemented:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (32) +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (30) +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:33:8 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: NotImplemented:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC5: NotImplemented:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace // CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC5: NotImplemented:{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:37:7 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC6 %s -// CHECK-CC6: NotImplemented:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace // CHECK-CC6-NOT: getSelf -// CHECK-CC6: NotImplemented:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace -// CHECK-CC6: NotImplemented:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:42:3 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC7 %s -// CHECK-CC7: NotImplemented:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace +// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace // RUN: c-index-test -code-completion-at=%s:52:21 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC8 %s // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{Text third:}{Text (double)z} (20) // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{Text third:}{Text (double)z} (20) @@ -99,5 +107,53 @@ // CHECK-CC9: NotImplemented:{TypedText xxx} (30) // RUN: c-index-test -code-completion-at=%s:52:36 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CCA %s // CHECK-CCA: NotImplemented:{TypedText y2} (30) - - +// RUN: c-index-test -code-completion-at=%s:56:3 %s | FileCheck -check-prefix=CHECK-CCB %s +// CHECK-CCB: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText first}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second2}{Colon :}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{Text third}{Colon :}{LeftParen (}{Text double}{RightParen )}{Text z} (30) +// RUN: c-index-test -code-completion-at=%s:56:8 %s | FileCheck -check-prefix=CHECK-CCC %s +// CHECK-CCC: ObjCInstanceMethodDecl:{TypedText first}{Colon :}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{Text second2}{Colon :}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{Text third}{Colon :}{LeftParen (}{Text double}{RightParen )}{Text z} (30) +// RUN: c-index-test -code-completion-at=%s:56:21 %s | FileCheck -check-prefix=CHECK-CCD %s +// FIXME: These results could be more precise. +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{Text third:}{Text (double)z} (20) +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second2:}{Text (float)y}{HorizontalSpace }{Text third:}{Text (double)z} (5) +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{Text third:}{Text (double)z} (20) +// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{Text third:}{Text (double)z} (5) +// RUN: c-index-test -code-completion-at=%s:56:38 %s | FileCheck -check-prefix=CHECK-CCE %s +// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (20) +// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (5) +// RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s +// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (65) +// CHECK-CCF: NotImplemented:{TypedText bycopy} (30) +// CHECK-CCF: NotImplemented:{TypedText byref} (30) +// CHECK-CCF: NotImplemented:{TypedText in} (30) +// CHECK-CCF: NotImplemented:{TypedText inout} (30) +// CHECK-CCF: NotImplemented:{TypedText oneway} (30) +// CHECK-CCF: NotImplemented:{TypedText out} (30) +// CHECK-CCF: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCF: NotImplemented:{TypedText void} (65) +// CHECK-CCF: NotImplemented:{TypedText volatile} (65) +// RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s +// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (65) +// CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (30) +// CHECK-CCG-NOT: NotImplemented:{TypedText byref} (30) +// CHECK-CCG: NotImplemented:{TypedText in} (30) +// CHECK-CCG: NotImplemented:{TypedText inout} (30) +// CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (30) +// CHECK-CCG: NotImplemented:{TypedText out} (30) +// CHECK-CCG: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCG: NotImplemented:{TypedText void} (65) +// CHECK-CCG: NotImplemented:{TypedText volatile} (65) +// RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s +// RUN: c-index-test -code-completion-at=%s:60:26 %s | FileCheck -check-prefix=CHECK-CCH %s +// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (65) +// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (65) +// CHECK-CCH: NotImplemented:{TypedText bycopy} (30) +// CHECK-CCH: NotImplemented:{TypedText byref} (30) +// CHECK-CCH-NOT: NotImplemented:{TypedText in} (30) +// CHECK-CCH: NotImplemented:{TypedText inout} (30) +// CHECK-CCH: NotImplemented:{TypedText oneway} (30) +// CHECK-CCH: NotImplemented:{TypedText out} (30) +// CHECK-CCH: NotImplemented:{TypedText unsigned} (65) +// CHECK-CCH: NotImplemented:{TypedText void} (65) +// CHECK-CCH: NotImplemented:{TypedText volatile} (65) diff --git a/test/Index/complete-natural.m b/test/Index/complete-natural.m new file mode 100644 index 0000000..e1aba39 --- /dev/null +++ b/test/Index/complete-natural.m @@ -0,0 +1,56 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +const char *in_string = "string"; +char in_char = 'a'; +// in comment +/* in comment */ +#warning blarg +#error blarg +#pragma mark this is the spot +// RUN: c-index-test -code-completion-at=%s:4:32 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// CHECK-CC1-NOT: : +// CHECK-CC1: DONE +// RUN: c-index-test -code-completion-at=%s:5:18 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:6:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:7:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:8:10 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:9:9 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: c-index-test -code-completion-at=%s:10:19 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t + +// Same tests as above, but with completion caching. +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:32 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:5:18 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:6:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:7 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:8:10 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:9 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:10:19 %s > %t +// RUN: echo "DONE" >> %t +// RUN: FileCheck -check-prefix=CHECK-CC1 %s < %t diff --git a/test/Index/complete-objc-message-id.m b/test/Index/complete-objc-message-id.m index a75ee4a..be42b9b 100644 --- a/test/Index/complete-objc-message-id.m +++ b/test/Index/complete-objc-message-id.m @@ -26,6 +26,11 @@ void message_id(B *b) { [[b superclass] B_method]; } +@implementation Unrelated ++ (id)alloc { + return [A alloc]; +} +@end // RUN: c-index-test -code-completion-at=%s:24:14 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText autorelease} // CHECK-CC1-NOT: B_method @@ -40,3 +45,10 @@ void message_id(B *b) { // CHECK-CC3: ObjCInstanceMethodDecl:{ResultType id}{TypedText retain} +// RUN: c-index-test -code-completion-at=%s:31:13 %s | FileCheck -check-prefix=CHECK-SELECTOR-PREF %s +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText alloc} (17) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText class} (20) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText init} (20) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType id}{TypedText new} (20) +// CHECK-SELECTOR-PREF: ObjCClassMethodDecl:{ResultType Class}{TypedText superclass} (20) + diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m index 321d75f..f9d6710 100644 --- a/test/Index/complete-objc-message.m +++ b/test/Index/complete-objc-message.m @@ -1,6 +1,6 @@ // Note: the run lines follow their respective tests, since line/column // matter in this test. - +#define nil (void*)0 @protocol FooTestProtocol + protocolClassMethod; - protocolInstanceMethod : (int)value; @@ -96,9 +96,9 @@ void test_overload(Overload *ovl) { } @interface Ellipsis -- (int)Method:(int)i, ...; +- (int)Method:(int)i, ...; +- (int)SentinelMethod:(int)i, ... __attribute__((sentinel(0,1))); @end - void f(Ellipsis *e) { [e Method:1, 2, 3]; } @@ -122,43 +122,55 @@ void msg_id(id x) { [id Method:1 Arg1:1 OtherArg:ovl]; } +@interface A +- (void)method1; +@end + +@interface B : A +- (void)method2; +@end + +void test_ranking(B *b) { + [b method1]; +} + // RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: {TypedText categoryClassMethod} -// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} +// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)} // CHECK-CC1: {TypedText classMethod2} // CHECK-CC1: {TypedText new} // CHECK-CC1: {TypedText protocolClassMethod} // RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: {TypedText categoryInstanceMethod} // CHECK-CC2: {TypedText instanceMethod1} -// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)} // RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s -// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} +// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)} // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} // RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{Text second:}{Placeholder (id)} // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} // RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s -// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{Text second:}{Placeholder (id)} // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} // RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s -// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)} // CHECK-CC6: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} // RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s // CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} // RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s // CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText } -// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s -// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} -// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} +// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)} +// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s // CHECK-CCA: TypedefDecl:{TypedText Class} // CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo} @@ -170,22 +182,23 @@ void msg_id(id x) { // CHECK-CCA: {ResultType Class}{TypedText self} // CHECK-CCA: {TypedText super} // RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s -// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}{Placeholder , ...} +// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int), ...} +// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText SentinelMethod:}{Placeholder (int), ...}{Text , nil} // RUN: c-index-test -code-completion-at=%s:116:14 %s | FileCheck -check-prefix=CHECK-CCC %s // CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} // RUN: c-index-test -code-completion-at=%s:116:23 %s | FileCheck -check-prefix=CHECK-CCD %s // CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText } -// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} +// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:116:30 %s | FileCheck -check-prefix=CHECK-CCE %s -// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} -// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} +// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)} +// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)} // RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCF %s // CHECK-CCF: TypedefDecl:{TypedText Class} // CHECK-CCF: ObjCInterfaceDecl:{TypedText Foo} @@ -199,31 +212,25 @@ void msg_id(id x) { // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText categoryInstanceMethod} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod1} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace }{Text second:}{Placeholder (id)} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod:}{Placeholder (id)obj} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} +// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)} // CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} // RUN: c-index-test -code-completion-at=%s:121:14 %s | FileCheck -check-prefix=CHECK-CCG %s // RUN: c-index-test -code-completion-at=%s:122:7 %s | FileCheck -check-prefix=CHECK-CCH %s // CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText categoryClassMethod} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)} // CHECK-CCH: ObjCClassMethodDecl:{ResultType void}{TypedText classMethod2} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubClassMethod} // CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubPrivateMethod} // CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText new} -// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} +// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)}{HorizontalSpace }{Text Arg1:}{Placeholder (int)}{HorizontalSpace }{Text Arg2:}{Placeholder (int)} // CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText protocolClassMethod} +// RUN: c-index-test -code-completion-at=%s:134:6 %s | FileCheck -check-prefix=CHECK-CCI %s +// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method1} (22) +// CHECK-CCI: ObjCInstanceMethodDecl:{ResultType void}{TypedText method2} (20) diff --git a/test/Index/complete-pch.m b/test/Index/complete-pch.m index 09192ae..517d49c 100644 --- a/test/Index/complete-pch.m +++ b/test/Index/complete-pch.m @@ -16,11 +16,11 @@ void msg_id(id x) { // Run the actual tests // RUN: c-index-test -code-completion-at=%s:10:7 -include %t.h %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (double)d} -// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod2:}{Placeholder (float)f} -// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod3:}{Placeholder (float)f} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (double)} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod2:}{Placeholder (float)} +// CHECK-CC1: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod3:}{Placeholder (float)} // RUN: c-index-test -code-completion-at=%s:11:6 -include %t.h %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod1:}{Placeholder (int)x} -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod2:}{Placeholder (int)x} -// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod3:}{Placeholder (int)x} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod1:}{Placeholder (int)} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod2:}{Placeholder (int)} +// CHECK-CC2: ObjCInstanceMethodDecl:{ResultType int}{TypedText instanceMethod3:}{Placeholder (int)} diff --git a/test/Index/complete-preprocessor.m b/test/Index/complete-preprocessor.m new file mode 100644 index 0000000..1873dad --- /dev/null +++ b/test/Index/complete-preprocessor.m @@ -0,0 +1,80 @@ +// The line and column layout of this test is significant. Run lines +// are at the end. + +#if 1 +#endif + +#define FOO(a, b) a##b +#define BAR +#ifdef FOO +#endif +#if defined(FOO) +#endif + +FOO(in,t) value; + +// RUN: c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText if}{HorizontalSpace }{Placeholder condition} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText ifdef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText ifndef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number}{HorizontalSpace }{Text "}{Placeholder filename}{Text "} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText pragma}{HorizontalSpace }{Placeholder arguments} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC1-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace }{Placeholder message} (30) +// RUN: c-index-test -code-completion-at=%s:5:2 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText define}{HorizontalSpace }{Placeholder macro}{LeftParen (}{Placeholder args}{RightParen )} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText elif}{HorizontalSpace }{Placeholder condition} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText else} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText endif} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText error}{HorizontalSpace }{Placeholder message} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText if}{HorizontalSpace }{Placeholder condition} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText ifdef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText ifndef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText import}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text "}{Placeholder header}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText include_next}{HorizontalSpace }{Text <}{Placeholder header}{Text >} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText line}{HorizontalSpace }{Placeholder number}{HorizontalSpace }{Text "}{Placeholder filename}{Text "} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText pragma}{HorizontalSpace }{Placeholder arguments} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText undef}{HorizontalSpace }{Placeholder macro} (30) +// CHECK-CC2-NEXT: NotImplemented:{TypedText warning}{HorizontalSpace }{Placeholder message} (30) +// RUN: c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: NotImplemented:{TypedText BAR} (30) +// CHECK-CC3: NotImplemented:{TypedText FOO} (30) +// RUN: c-index-test -code-completion-at=%s:11:12 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: c-index-test -code-completion-at=%s:11:13 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: macro definition:{TypedText BAR} (70) +// CHECK-CC4: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70) +// RUN: c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{TypedText const} (65) +// CHECK-CC5: NotImplemented:{TypedText double} (65) +// CHECK-CC5: NotImplemented:{TypedText enum} (65) +// CHECK-CC5: NotImplemented:{TypedText extern} (30) +// CHECK-CC5: NotImplemented:{TypedText float} (65) +// CHECK-CC5: macro definition:{TypedText FOO}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (70) +// CHECK-CC5: TypedefDecl:{TypedText id} (65) +// CHECK-CC5: NotImplemented:{TypedText inline} (30) +// CHECK-CC5: NotImplemented:{TypedText int} (65) +// CHECK-CC5: NotImplemented:{TypedText long} (65) + +// Same tests as above, but with completion caching. +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:4:2 %s | FileCheck -check-prefix=CHECK-CC1 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:5:2 %s | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:9:8 %s | FileCheck -check-prefix=CHECK-CC3 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:11:5 %s | FileCheck -check-prefix=CHECK-CC4 %s +// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:14:5 %s | FileCheck -check-prefix=CHECK-CC5 %s diff --git a/test/Index/complete-recovery.m b/test/Index/complete-recovery.m index e03834e..fbd92c7 100644 --- a/test/Index/complete-recovery.m +++ b/test/Index/complete-recovery.m @@ -18,7 +18,7 @@ // CHECK-CC1: VarDecl:{ResultType A *}{TypedText a} // CHECK-CC1: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} -// RUN: c-index-test -code-completion-at=%s:10:24 -Xclang -code-completion-patterns %s 2>%t | FileCheck -check-prefix=CHECK-CC2 %s +// RUN: c-index-test -code-completion-at=%s:10:24 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: NotImplemented:{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )} // CHECK-CC2: NotImplemented:{TypedText _Bool} // CHECK-CC2: VarDecl:{ResultType A *}{TypedText a} diff --git a/test/Index/complete-super.cpp b/test/Index/complete-super.cpp new file mode 100644 index 0000000..49f94e4 --- /dev/null +++ b/test/Index/complete-super.cpp @@ -0,0 +1,33 @@ +// The run lines are below, because this test is line- and +// column-number sensitive. + +struct A { + virtual void foo(int x, int y); + virtual void bar(double x); + virtual void bar(float x); +}; + +struct B : A { + void foo(int a, int b); + void bar(float real); +}; + +void B::foo(int a, int b) { + A::foo(a, b); +} + +void B::bar(float real) { + A::bar(real); +} + +// RUN: c-index-test -code-completion-at=%s:16:3 %s | FileCheck -check-prefix=CHECK-FOO-UNQUAL %s +// CHECK-FOO-UNQUAL: CXXMethod:{Text A::}{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (8) + +// RUN: c-index-test -code-completion-at=%s:20:3 %s | FileCheck -check-prefix=CHECK-BAR-UNQUAL %s +// CHECK-BAR-UNQUAL: CXXMethod:{Text A::}{TypedText bar}{LeftParen (}{Placeholder real}{RightParen )} (8) +// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{TypedText bar}{LeftParen (}{Placeholder float real}{RightParen )} (14) +// CHECK-BAR-UNQUAL: CXXMethod:{ResultType void}{Text A::}{TypedText bar}{LeftParen (}{Placeholder double x}{RightParen )} (16) + +// RUN: c-index-test -code-completion-at=%s:16:6 %s | FileCheck -check-prefix=CHECK-FOO-QUAL %s +// CHECK-FOO-QUAL: CXXMethod:{TypedText foo}{LeftParen (}{Placeholder a}{Comma , }{Placeholder b}{RightParen )} (8) + diff --git a/test/Index/complete-super.m b/test/Index/complete-super.m new file mode 100644 index 0000000..fc60c6c --- /dev/null +++ b/test/Index/complete-super.m @@ -0,0 +1,55 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +typedef int Bool; + +@interface A +- (void)add:(int)x to:(int)y; ++ (void)select:(Bool)condition first:(int)x second:(int)y; +- (void)last; ++ (void)last; +@end + +@interface B : A +- (void)add:(int)x to:(int)y; ++ (void)select:(Bool)condition first:(int)x second:(int)y; +@end + +@implementation B +- (void)add:(int)a to:(int)b { + [super add:a to:b]; +} + ++ (void)select:(Bool)condition first:(int)a second:(int)b { + [super selector:condition first:a second:b]; +} +@end + +// Check "super" completion as a message receiver. +// RUN: c-index-test -code-completion-at=%s:20:4 %s | FileCheck -check-prefix=CHECK-ADD-RECEIVER %s +// CHECK-ADD-RECEIVER: ObjCInstanceMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace }{Text add:}{Placeholder a}{HorizontalSpace }{Text to:}{Placeholder b} (8) + +// RUN: c-index-test -code-completion-at=%s:24:4 %s | FileCheck -check-prefix=CHECK-SELECT-RECEIVER %s +// CHECK-SELECT-RECEIVER: ObjCClassMethodDecl:{ResultType void}{TypedText super}{HorizontalSpace }{Text select:}{Placeholder condition}{HorizontalSpace }{Text first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (8) + +// Check "super" completion at the first identifier +// RUN: c-index-test -code-completion-at=%s:20:10 %s | FileCheck -check-prefix=CHECK-ADD-ADD %s +// CHECK-ADD-ADD: ObjCInstanceMethodDecl:{ResultType void}{TypedText add:}{Placeholder a}{HorizontalSpace }{Text to:}{Placeholder b} (8) +// CHECK-ADD-ADD-NOT: add +// CHECK-ADD-ADD: ObjCInstanceMethodDecl:{ResultType void}{TypedText last} (20) + +// RUN: c-index-test -code-completion-at=%s:24:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s +// CHECK-SELECTOR-SELECTOR-NOT: x +// CHECK-SELECTOR-SELECTOR: ObjCClassMethodDecl:{ResultType void}{TypedText last} (20) +// CHECK-SELECTOR-SELECTOR: ObjCClassMethodDecl:{ResultType void}{TypedText select:}{Placeholder condition}{HorizontalSpace }{Text first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (8) + +// Check "super" completion at the second identifier +// RUN: c-index-test -code-completion-at=%s:20:16 %s | FileCheck -check-prefix=CHECK-ADD-TO %s +// CHECK-ADD-TO: ObjCInstanceMethodDecl:{ResultType void}{Informative add:}{TypedText to:}{Placeholder b} (8) + +// RUN: c-index-test -code-completion-at=%s:24:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s +// CHECK-SELECTOR-FIRST: ObjCClassMethodDecl:{ResultType void}{Informative select:}{TypedText first:}{Placeholder a}{HorizontalSpace }{Text second:}{Placeholder b} (8) + +// Check "super" completion at the third identifier +// RUN: c-index-test -code-completion-at=%s:24:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s +// CHECK-SELECTOR-SECOND: ObjCClassMethodDecl:{ResultType void}{Informative select:}{Informative first:}{TypedText second:}{Placeholder b} (8) diff --git a/test/Index/complete-templates.cpp b/test/Index/complete-templates.cpp new file mode 100644 index 0000000..2f2302d --- /dev/null +++ b/test/Index/complete-templates.cpp @@ -0,0 +1,19 @@ +// Tests are line- and column-sensive, so run lines are below. + +template<typename T> +class X { + X(); + X(const X&); + + template<typename U> X(U); +}; + +template<typename T> void f(T); + +void test() { + +} + +// RUN: c-index-test -code-completion-at=%s:14:2 %s | FileCheck %s +// CHECK: FunctionTemplate:{ResultType void}{TypedText f}{LeftParen (}{Placeholder T}{RightParen )} (45) +// CHECK: ClassTemplate:{TypedText X}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50) diff --git a/test/Index/complete-unterminated.c b/test/Index/complete-unterminated.c new file mode 100644 index 0000000..56e6ae1 --- /dev/null +++ b/test/Index/complete-unterminated.c @@ -0,0 +1,30 @@ +typedef int Integer; + +#if 0 + + +#endif + +/* blah */ + +void f0(const char*); +void f1(char); + +const char *hello = "Hello, world"; +const char a = 'a'; + +#define FOO(a, b) a b + +FOO(int, x); + +// RUN: c-index-test -code-completion-at=%s:5:1 -pedantic %s 2> %t.err | FileCheck %s +// RUN: not grep error %t.err +// CHECK: {TypedText Integer} +// RUN: c-index-test -code-completion-at=%s:8:6 -pedantic %s 2> %t.err +// RUN: not grep error %t.err +// RUN: c-index-test -code-completion-at=%s:10:28 -pedantic %s 2> %t.err +// RUN: not grep unterminated %t.err +// RUN: c-index-test -code-completion-at=%s:11:17 -pedantic %s 2> %t.err +// RUN: not grep unterminated %t.err +// RUN: c-index-test -code-completion-at=%s:18:10 -pedantic %s 2> %t.err +// RUN: not grep unterminated %t.err diff --git a/test/Index/crash-recovery-code-complete.c b/test/Index/crash-recovery-code-complete.c new file mode 100644 index 0000000..a80bdc2 --- /dev/null +++ b/test/Index/crash-recovery-code-complete.c @@ -0,0 +1,10 @@ +// RUN: env CINDEXTEST_EDITING=1 \ +// RUN: not c-index-test -code-completion-at=%s:20:1 \ +// RUN: "-remap-file=%s;%S/Inputs/crash-recovery-code-complete-remap.c" \ +// RUN: %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-CODE-COMPLETE-CRASH %s +// CHECK-CODE-COMPLETE-CRASH: Unable to perform code completion! +// +// REQUIRES: crash-recovery + +#warning parsing original file diff --git a/test/Index/crash-recovery-reparse.c b/test/Index/crash-recovery-reparse.c new file mode 100644 index 0000000..e394bd1 --- /dev/null +++ b/test/Index/crash-recovery-reparse.c @@ -0,0 +1,10 @@ +// RUN: env CINDEXTEST_EDITING=1 \ +// RUN: not c-index-test -test-load-source-reparse 1 local \ +// RUN: -remap-file="%s;%S/Inputs/crash-recovery-reparse-remap.c" \ +// RUN: %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-REPARSE-SOURCE-CRASH %s +// CHECK-REPARSE-SOURCE-CRASH: Unable to reparse translation unit +// +// REQUIRES: crash-recovery + +#warning parsing original file diff --git a/test/Index/crash-recovery.c b/test/Index/crash-recovery.c new file mode 100644 index 0000000..b7f6e0b --- /dev/null +++ b/test/Index/crash-recovery.c @@ -0,0 +1,7 @@ +// RUN: not c-index-test -test-load-source all %s 2> %t.err +// RUN: FileCheck < %t.err -check-prefix=CHECK-LOAD-SOURCE-CRASH %s +// CHECK-LOAD-SOURCE-CRASH: Unable to load translation unit +// +// REQUIRES: crash-recovery + +#pragma clang __debug crash diff --git a/test/Index/index-templates.cpp b/test/Index/index-templates.cpp new file mode 100644 index 0000000..a4f1ee8 --- /dev/null +++ b/test/Index/index-templates.cpp @@ -0,0 +1,147 @@ +// Test is line- and column-sensitive. See run lines below. + +template<typename T, T Value, template<typename U, U ValU> class X> +void f(X<T, Value> x); + +template<typename T> class allocator; + +template<typename T, typename Alloc = allocator<T> > +class vector { + void clear(); +}; + +template<typename T> +class vector<T*> { }; + +struct Z1 { }; + +template class vector<Z1>; + +struct Z2 { }; + +template<> +class vector<Z2> { + void clear(); +}; + +template<typename T, typename U> +struct Y { + using typename T::type; + using U::operator Z2; +}; + +struct Z3 { }; + +const unsigned OneDimension = 1; +template<typename T, unsigned Dimensions = OneDimension> +struct array { }; + +template<template<typename, unsigned> class DataStructure = array> +struct storage { }; + +typedef unsigned Unsigned; + +template<typename T, Unsigned Value> +struct value_c; + +template class vector<int*>; + +struct Z4 { + template<typename T> T getAs(); +}; + +void template_exprs() { + f<Unsigned, OneDimension, array>(array<Unsigned, OneDimension>()); + Z4().getAs<Unsigned>(); +} + +// RUN: c-index-test -test-load-source all %s | FileCheck -check-prefix=CHECK-LOAD %s +// CHECK-LOAD: index-templates.cpp:4:6: FunctionTemplate=f:4:6 Extent=[3:1 - 4:22] +// CHECK-LOAD: index-templates.cpp:3:19: TemplateTypeParameter=T:3:19 (Definition) Extent=[3:19 - 3:20] +// CHECK-LOAD: index-templates.cpp:3:24: NonTypeTemplateParameter=Value:3:24 (Definition) Extent=[3:22 - 3:29] +// FIXME: Need the template type parameter here +// CHECK-LOAD: index-templates.cpp:3:66: TemplateTemplateParameter=X:3:66 (Definition) Extent=[3:31 - 3:67] +// CHECK-LOAD: index-templates.cpp:4:20: ParmDecl=x:4:20 (Definition) Extent=[4:8 - 4:21] +// CHECK-LOAD: index-templates.cpp:4:8: TemplateRef=X:3:66 Extent=[4:8 - 4:9] +// FIXME: Need the template type parameter here +// CHECK-LOAD: index-templates.cpp:4:13: DeclRefExpr=Value:3:24 Extent=[4:13 - 4:18] +// CHECK-LOAD: index-templates.cpp:6:28: ClassTemplate=allocator:6:28 Extent=[6:1 - 6:37] +// CHECK-LOAD: index-templates.cpp:6:19: TemplateTypeParameter=T:6:19 (Definition) Extent=[6:19 - 6:20] +// CHECK-LOAD: index-templates.cpp:9:7: ClassTemplate=vector:9:7 (Definition) Extent=[8:1 - 11:2] +// CHECK-LOAD: index-templates.cpp:8:19: TemplateTypeParameter=T:8:19 (Definition) Extent=[8:19 - 8:20] +// CHECK-LOAD: index-templates.cpp:8:31: TemplateTypeParameter=Alloc:8:31 (Definition) Extent=[8:31 - 8:36] +// CHECK-LOAD: index-templates.cpp:8:39: TemplateRef=allocator:6:28 Extent=[8:39 - 8:48] +// CHECK-LOAD: index-templates.cpp:10:8: CXXMethod=clear:10:8 Extent=[10:8 - 10:15] +// CHECK-LOAD: index-templates.cpp:14:7: ClassTemplatePartialSpecialization=vector:14:7 (Definition) [Specialization of vector:9:7] Extent=[13:1 - 14:21] +// CHECK-LOAD: index-templates.cpp:13:19: TemplateTypeParameter=T:13:19 (Definition) Extent=[13:19 - 13:20] +// CHECK-LOAD: index-templates.cpp:16:8: StructDecl=Z1:16:8 (Definition) Extent=[16:1 - 16:14] +// CHECK-LOAD: index-templates.cpp:18:16: ClassDecl=vector:18:16 (Definition) [Specialization of vector:9:7] Extent=[18:1 - 18:22] +// CHECK-LOAD: index-templates.cpp:18:23: TypeRef=struct Z1:16:8 Extent=[18:23 - 18:25] +// CHECK-LOAD-NOT: CXXMethod=clear +// CHECK-LOAD: index-templates.cpp:20:8: StructDecl=Z2:20:8 (Definition) Extent=[20:1 - 20:14] +// CHECK-LOAD: index-templates.cpp:23:7: ClassDecl=vector:23:7 (Definition) [Specialization of vector:9:7] Extent=[22:1 - 25:2] +// CHECK-LOAD: index-templates.cpp:23:14: TypeRef=struct Z2:20:8 Extent=[23:14 - 23:16] +// CHECK-LOAD: index-templates.cpp:24:8: CXXMethod=clear:24:8 Extent=[24:8 - 24:15] +// CHECK-LOAD: index-templates.cpp:28:8: ClassTemplate=Y:28:8 (Definition) Extent=[27:1 - 31:2] +// CHECK-LOAD: index-templates.cpp:27:19: TemplateTypeParameter=T:27:19 (Definition) Extent=[27:19 - 27:20] +// CHECK-LOAD: index-templates.cpp:27:31: TemplateTypeParameter=U:27:31 (Definition) Extent=[27:31 - 27:32] +// CHECK-LOAD: index-templates.cpp:29:21: UsingDeclaration=type:29:21 Extent=[29:3 - 29:25] +// CHECK-LOAD: index-templates.cpp:30:12: UsingDeclaration=operator Z2:30:12 Extent=[30:3 - 30:23] +// CHECK-LOAD: index-templates.cpp:30:21: TypeRef=struct Z2:20:8 Extent=[30:21 - 30:23] +// CHECK-LOAD: index-templates.cpp:35:16: VarDecl=OneDimension:35:16 (Definition) Extent=[35:7 - 35:32] +// CHECK-LOAD: index-templates.cpp:35:31: UnexposedExpr= Extent=[35:31 - 35:32] +// CHECK-LOAD: index-templates.cpp:35:31: UnexposedExpr= Extent=[35:31 - 35:32] +// CHECK-LOAD: index-templates.cpp:37:8: ClassTemplate=array:37:8 (Definition) Extent=[36:1 - 37:17] +// CHECK-LOAD: index-templates.cpp:36:19: TemplateTypeParameter=T:36:19 (Definition) Extent=[36:19 - 36:20] +// CHECK-LOAD: index-templates.cpp:36:31: NonTypeTemplateParameter=Dimensions:36:31 (Definition) Extent=[36:22 - 36:41] +// CHECK-LOAD: index-templates.cpp:36:44: DeclRefExpr=OneDimension:35:16 Extent=[36:44 - 36:56] +// CHECK-LOAD: index-templates.cpp:40:8: ClassTemplate=storage:40:8 (Definition) Extent=[39:1 - 40:19] +// CHECK-LOAD: index-templates.cpp:39:45: TemplateTemplateParameter=DataStructure:39:45 (Definition) Extent=[39:10 - 39:66] +// CHECK-LOAD: index-templates.cpp:39:19: TemplateTypeParameter=:39:19 (Definition) Extent=[39:19 - 39:27] +// CHECK-LOAD: index-templates.cpp:39:37: NonTypeTemplateParameter=:39:37 (Definition) Extent=[39:29 - 39:38] +// CHECK-LOAD: index-templates.cpp:39:61: TemplateRef=array:37:8 Extent=[39:61 - 39:66] +// CHECK-LOAD: index-templates.cpp:42:18: TypedefDecl=Unsigned:42:18 (Definition) Extent=[42:18 - 42:26] +// CHECK-LOAD: index-templates.cpp:45:8: ClassTemplate=value_c:45:8 Extent=[44:1 - 45:15] +// CHECK-LOAD: index-templates.cpp:44:19: TemplateTypeParameter=T:44:19 (Definition) Extent=[44:19 - 44:20] +// CHECK-LOAD: index-templates.cpp:44:31: NonTypeTemplateParameter=Value:44:31 (Definition) Extent=[44:22 - 44:36] +// CHECK-LOAD: index-templates.cpp:44:22: TypeRef=Unsigned:42:18 Extent=[44:22 - 44:30] +// CHECK-LOAD: index-templates.cpp:47:16: ClassDecl=vector:47:16 (Definition) [Specialization of vector:14:7] Extent=[47:1 - 47:22] +// CHECK-LOAD: index-templates.cpp:49:8: StructDecl=Z4:49:8 (Definition) Extent=[49:1 - 51:2] +// CHECK-LOAD: index-templates.cpp:50:26: FunctionTemplate=getAs:50:26 Extent=[50:3 - 50:33] +// CHECK-LOAD: index-templates.cpp:50:21: TemplateTypeParameter=T:50:21 (Definition) Extent=[50:21 - 50:22] +// CHECK-LOAD: index-templates.cpp:53:6: FunctionDecl=template_exprs:53:6 (Definition) +// CHECK-LOAD: <invalid loc>:0:0: UnexposedStmt= +// CHECK-LOAD: index-templates.cpp:54:3: CallExpr=f:4:6 Extent=[54:3 - 54:68] +// CHECK-LOAD: index-templates.cpp:54:3: UnexposedExpr=f:4:6 Extent=[54:3 - 54:35] +// CHECK-LOAD: index-templates.cpp:54:3: DeclRefExpr=f:4:6 Extent=[54:3 - 54:35] +// CHECK-LOAD: index-templates.cpp:54:5: TypeRef=Unsigned:42:18 Extent=[54:5 - 54:13] +// CHECK-LOAD: index-templates.cpp:54:15: DeclRefExpr=OneDimension:35:16 Extent=[54:15 - 54:27] +// CHECK-LOAD: index-templates.cpp:54:29: TemplateRef=array:37:8 Extent=[54:29 - 54:34] +// CHECK-LOAD: index-templates.cpp:55:8: MemberRefExpr=getAs:50:26 Extent=[55:3 - 55:23] +// CHECK-LOAD: index-templates.cpp:55:3: CallExpr= Extent=[55:3 - 55:7] +// CHECK-LOAD: index-templates.cpp:55:14: TypeRef=Unsigned:42:18 Extent=[55:14 - 55:22] + +// RUN: c-index-test -test-load-source-usrs all %s | FileCheck -check-prefix=CHECK-USRS %s +// CHECK-USRS: index-templates.cpp c:@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22t0.0# Extent=[3:1 - 4:22] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@79 Extent=[3:19 - 3:20] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@82 Extent=[3:22 - 3:29] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@91 Extent=[3:31 - 3:67] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@136@FT@>3#T#Nt0.0#t>2#T#Nt1.0f#>t0.22t0.0#@x Extent=[4:8 - 4:21] +// CHECK-USRS: index-templates.cpp c:@CT>1#T@allocator Extent=[6:1 - 6:37] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@171 Extent=[6:19 - 6:20] +// CHECK-USRS: index-templates.cpp c:@CT>2#T#T@vector Extent=[8:1 - 11:2] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@210 Extent=[8:19 - 8:20] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@222 Extent=[8:31 - 8:36] +// CHECK-USRS: index-templates.cpp c:@CT>2#T#T@vector@F@clear# Extent=[10:8 - 10:15] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@280@CP>1#T@vector>#*t0.0#>@CT>1#T@allocator1*t0.0 Extent=[13:1 - 14:21] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@298 Extent=[13:19 - 13:20] +// CHECK-USRS: index-templates.cpp c:@S@Z1 Extent=[16:1 - 16:14] +// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z1#$@C@allocator>#$@S@Z1 Extent=[18:1 - 18:22] +// CHECK-USRS: index-templates.cpp c:@S@Z2 Extent=[20:1 - 20:14] +// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z2#$@C@allocator>#$@S@Z2 Extent=[22:1 - 25:2] +// CHECK-USRS: index-templates.cpp c:@C@vector>#$@S@Z2#$@C@allocator>#$@S@Z2@F@clear# Extent=[24:8 - 24:15] +// CHECK-USRS: index-templates.cpp c:@ST>2#T#T@Y Extent=[27:1 - 31:2] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@452 Extent=[27:19 - 27:20] +// CHECK-USRS: index-templates.cpp c:index-templates.cpp@464 Extent=[27:31 - 27:32] +// CHECK-USRS-NOT: type +// CHECK-USRS: index-templates.cpp c:@S@Z3 Extent=[33:1 - 33:14] diff --git a/test/Index/invalid-rdar-8236270.cpp b/test/Index/invalid-rdar-8236270.cpp new file mode 100644 index 0000000..6fd088d --- /dev/null +++ b/test/Index/invalid-rdar-8236270.cpp @@ -0,0 +1,11 @@ +// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s + +// This test case previously just crashed the frontend. + +struct abc *P; +int main( + +// CHECK: StructDecl=abc:5:8 Extent=[5:1 - 5:11] +// CHECK: VarDecl=P:5:13 (Definition) Extent=[5:8 - 5:14] +// CHECK: VarDecl=main:6:5 (Definition) Extent=[6:1 - 6:9] + diff --git a/test/Index/load-classes.cpp b/test/Index/load-classes.cpp new file mode 100644 index 0000000..349ebde --- /dev/null +++ b/test/Index/load-classes.cpp @@ -0,0 +1,28 @@ +// Test is line- and column-sensitive; see below. + +struct X { + X(int value); + X(const X& x); + ~X(); + operator X*(); +}; + +X::X(int value) { +} + +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 8:2] +// CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 Extent=[4:3 - 4:15] +// FIXME: missing TypeRef in the constructor name +// CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14] +// CHECK: load-classes.cpp:5:3: CXXConstructor=X:5:3 Extent=[5:3 - 5:16] +// FIXME: missing TypeRef in the constructor name +// CHECK: load-classes.cpp:5:14: ParmDecl=x:5:14 (Definition) Extent=[5:11 - 5:15] +// CHECK: load-classes.cpp:5:11: TypeRef=struct X:3:8 Extent=[5:11 - 5:12] +// CHECK: load-classes.cpp:6:3: CXXDestructor=~X:6:3 Extent=[6:3 - 6:7] +// FIXME: missing TypeRef in the destructor name +// CHECK: load-classes.cpp:7:3: CXXConversion=operator struct X *:7:3 Extent=[7:3 - 7:16] +// CHECK: load-classes.cpp:7:12: TypeRef=struct X:3:8 Extent=[7:12 - 7:13] +// CHECK: load-classes.cpp:10:4: CXXConstructor=X:10:4 (Definition) Extent=[10:4 - 11:2] +// CHECK: load-classes.cpp:10:1: TypeRef=struct X:3:8 Extent=[10:1 - 10:2] +// CHECK: load-classes.cpp:10:10: ParmDecl=value:10:10 (Definition) Extent=[10:6 - 10:15] diff --git a/test/Index/load-decls.c b/test/Index/load-decls.c new file mode 100644 index 0000000..cf88f42 --- /dev/null +++ b/test/Index/load-decls.c @@ -0,0 +1,16 @@ +enum Color { + Red, + Green, + Blue, + + Rouge = Red +}; + +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// CHECK: load-decls.c:1:6: EnumDecl=Color:1:6 (Definition) Extent=[1:1 - 7:2] +// CHECK: load-decls.c:2:3: EnumConstantDecl=Red:2:3 (Definition) Extent=[2:3 - 2:6] +// CHECK: load-decls.c:3:3: EnumConstantDecl=Green:3:3 (Definition) Extent=[3:3 - 3:8] +// CHECK: load-decls.c:4:3: EnumConstantDecl=Blue:4:3 (Definition) Extent=[4:3 - 4:7] +// CHECK: load-decls.c:6:3: EnumConstantDecl=Rouge:6:3 (Definition) Extent=[6:3 - 6:14] +// CHECK: load-decls.c:6:11: UnexposedExpr=Red:2:3 Extent=[6:11 - 6:14] +// CHECK: load-decls.c:6:11: DeclRefExpr=Red:2:3 Extent=[6:11 - 6:14] diff --git a/test/Index/load-namespaces.cpp b/test/Index/load-namespaces.cpp new file mode 100644 index 0000000..241e241 --- /dev/null +++ b/test/Index/load-namespaces.cpp @@ -0,0 +1,50 @@ +// Test is line- and column-sensitive; see below. + +namespace std { + namespace rel_ops { + void f(); + } +} + +namespace std { + void g(); +} + +namespace std98 = std; +namespace std0x = std98; + +using namespace std0x; + +namespace std { + int g(int); +} + +using std::g; + +void std::g() { +} + +namespace my_rel_ops = std::rel_ops; + +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// CHECK: load-namespaces.cpp:3:11: Namespace=std:3:11 (Definition) Extent=[3:11 - 7:2] +// CHECK: load-namespaces.cpp:4:13: Namespace=rel_ops:4:13 (Definition) Extent=[4:13 - 6:4] +// CHECK: load-namespaces.cpp:5:10: FunctionDecl=f:5:10 Extent=[5:10 - 5:13] +// CHECK: load-namespaces.cpp:9:11: Namespace=std:9:11 (Definition) Extent=[9:11 - 11:2] +// CHECK: load-namespaces.cpp:10:8: FunctionDecl=g:10:8 Extent=[10:8 - 10:11] +// CHECK: load-namespaces.cpp:13:11: NamespaceAlias=std98:13:11 Extent=[13:1 - 13:22] +// CHECK: load-namespaces.cpp:13:19: NamespaceRef=std:3:11 Extent=[13:19 - 13:22] +// CHECK: load-namespaces.cpp:14:11: NamespaceAlias=std0x:14:11 Extent=[14:1 - 14:24] +// CHECK: load-namespaces.cpp:14:19: NamespaceRef=std98:13:11 Extent=[14:19 - 14:24] +// CHECK: load-namespaces.cpp:16:17: UsingDirective=:16:17 Extent=[16:1 - 16:22] +// CHECK: load-namespaces.cpp:16:17: NamespaceRef=std0x:14:11 Extent=[16:17 - 16:22] +// CHECK: load-namespaces.cpp:18:11: Namespace=std:18:11 (Definition) Extent=[18:11 - 20:2] +// CHECK: load-namespaces.cpp:19:7: FunctionDecl=g:19:7 Extent=[19:7 - 19:13] +// CHECK: load-namespaces.cpp:19:12: ParmDecl=:19:12 (Definition) Extent=[19:9 - 19:13] +// CHECK: load-namespaces.cpp:22:12: UsingDeclaration=g:22:12 Extent=[22:1 - 22:13] +// CHECK: load-namespaces.cpp:22:7: NamespaceRef=std:18:11 Extent=[22:7 - 22:10] +// CHECK: load-namespaces.cpp:24:11: FunctionDecl=g:24:11 (Definition) Extent=[24:11 - 25:2] +// CHECK: load-namespaces.cpp:24:6: NamespaceRef=std:18:11 Extent=[24:6 - 24:9] +// CHECK: load-namespaces.cpp:27:11: NamespaceAlias=my_rel_ops:27:11 Extent=[27:1 - 27:36] +// CHECK: load-namespaces.cpp:27:24: NamespaceRef=std:18:11 Extent=[27:24 - 27:27] +// CHECK: load-namespaces.cpp:27:29: NamespaceRef=rel_ops:4:13 Extent=[27:29 - 27:36] diff --git a/test/Index/load-stmts.cpp b/test/Index/load-stmts.cpp index cb99aee..503219f 100644 --- a/test/Index/load-stmts.cpp +++ b/test/Index/load-stmts.cpp @@ -10,6 +10,66 @@ void f(int x) { } } +// Test handling of C++ base specifiers. +class A { + void doA(); +}; + +class B { + void doB(); +}; + +class C : public A, private B { + void doC(); +}; + +class D : virtual public C, virtual private A {}; + +namespace std { + class type_info { }; +} + +void test_exprs(C *c) { + int typeid_marker; + typeid(C); + typeid(c); + typedef int Integer; + Integer *int_ptr; + int_ptr->Integer::~Integer(); +} + +namespace N { + int f(int); + float f(float); + + template<typename T> T g(T); + template<typename T> T g(T*); +} + +template<typename T> +void test_dependent_exprs(T t) { + N::f(t); + typedef T type; + N::g<type>(t); + type::template f<type*>(t); + t->type::template f<type*>(); +} + +struct Y { + int f(int); + float f(float); + + template<typename T> T g(T); + template<typename T> T g(T*); +}; + +template<typename T> +void test_more_dependent_exprs(T t, Y y) { + y.Y::f(t); + typedef T type; + y.g<type>(t); +} + // RUN: c-index-test -test-load-source all %s | FileCheck %s // CHECK: load-stmts.cpp:1:13: TypedefDecl=T:1:13 (Definition) Extent=[1:13 - 1:14] // CHECK: load-stmts.cpp:2:8: StructDecl=X:2:8 (Definition) Extent=[2:1 - 2:23] @@ -56,4 +116,47 @@ void f(int x) { // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:3 - 9:17] // CHECK: load-stmts.cpp:9:8: UnexposedExpr= Extent=[9:8 - 9:10] // CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:12 - 9:17] - +// CHECK: load-stmts.cpp:14:7: ClassDecl=A:14:7 (Definition) Extent=[14:1 - 16:2] +// CHECK: load-stmts.cpp:15:8: CXXMethod=doA:15:8 Extent=[15:8 - 15:13] +// CHECK: load-stmts.cpp:18:7: ClassDecl=B:18:7 (Definition) Extent=[18:1 - 20:2] +// CHECK: load-stmts.cpp:19:8: CXXMethod=doB:19:8 Extent=[19:8 - 19:13] +// CHECK: load-stmts.cpp:22:7: ClassDecl=C:22:7 (Definition) Extent=[22:1 - 24:2] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=public isVirtual=false] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class B:18:7 [access=private isVirtual=false] +// CHECK: load-stmts.cpp:23:8: CXXMethod=doC:23:8 Extent=[23:8 - 23:13] +// CHECK: load-stmts.cpp:26:7: ClassDecl=D:26:7 (Definition) Extent=[26:1 - 26:49] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class C:22:7 [access=public isVirtual=true] +// CHECK: <invalid loc>:0:0: C++ base class specifier=class A:14:7 [access=private isVirtual=true] +// CHECK: load-stmts.cpp:33:7: VarDecl=typeid_marker:33:7 (Definition) +// CHECK: load-stmts.cpp:34:10: TypeRef=class C:22:7 Extent=[34:10 - 34:11] +// CHECK: load-stmts.cpp:35:10: DeclRefExpr=c:32:20 Extent=[35:10 - 35:11] +// CHECK: load-stmts.cpp:37:12: VarDecl=int_ptr:37:12 (Definition) Extent=[37:3 - 37:19] +// CHECK: load-stmts.cpp:37:3: TypeRef=Integer:36:15 Extent=[37:3 - 37:10] +// CHECK: load-stmts.cpp:38:3: DeclRefExpr=int_ptr:37:12 Extent=[38:3 - 38:10] +// CHECK: load-stmts.cpp:38:12: TypeRef=Integer:36:15 Extent=[38:12 - 38:19] +// CHECK: load-stmts.cpp:38:22: TypeRef=Integer:36:15 Extent=[38:22 - 38:29] +// CHECK: load-stmts.cpp:50:6: FunctionTemplate=test_dependent_exprs:50:6 (Definition) +// CHECK: load-stmts.cpp:51:3: CallExpr= Extent=[51:3 - 51:10] +// CHECK: load-stmts.cpp:51:3: NamespaceRef=N:41:11 Extent=[51:3 - 51:4] +// CHECK: load-stmts.cpp:51:8: DeclRefExpr=t:50:29 Extent=[51:8 - 51:9] +// CHECK: load-stmts.cpp:52:13: TypedefDecl=type:52:13 (Definition) Extent=[52:13 - 52:17] +// CHECK: load-stmts.cpp:53:3: CallExpr= Extent=[53:3 - 53:16] +// CHECK: load-stmts.cpp:53:3: NamespaceRef=N:41:11 Extent=[53:3 - 53:4] +// CHECK: load-stmts.cpp:53:8: TypeRef=type:52:13 Extent=[53:8 - 53:12] +// CHECK: load-stmts.cpp:53:14: DeclRefExpr=t:50:29 Extent=[53:14 - 53:15] +// CHECK: load-stmts.cpp:54:3: CallExpr= Extent=[54:3 - 54:29] +// CHECK: load-stmts.cpp:54:3: TypeRef=type:52:13 Extent=[54:3 - 54:7] +// CHECK: load-stmts.cpp:54:20: TypeRef=type:52:13 Extent=[54:20 - 54:24] +// CHECK: load-stmts.cpp:54:27: DeclRefExpr=t:50:29 Extent=[54:27 - 54:28] +// CHECK: load-stmts.cpp:55:3: CallExpr= Extent=[55:3 - 55:31] +// CHECK: load-stmts.cpp:55:3: DeclRefExpr=t:50:29 Extent=[55:3 - 55:4] +// CHECK: load-stmts.cpp:55:23: TypeRef=type:52:13 Extent=[55:23 - 55:27] +// CHECK: load-stmts.cpp:67:6: FunctionTemplate=test_more_dependent_exprs:67:6 (Definition) +// CHECK: load-stmts.cpp:68:3: CallExpr= Extent=[68:3 - 68:12] +// CHECK: load-stmts.cpp:68:3: DeclRefExpr=y:67:39 Extent=[68:3 - 68:4] +// CHECK: load-stmts.cpp:68:5: TypeRef=struct Y:58:8 Extent=[68:5 - 68:6] +// CHECK: load-stmts.cpp:68:10: DeclRefExpr=t:67:34 Extent=[68:10 - 68:11] +// CHECK: load-stmts.cpp:70:3: CallExpr= Extent=[70:3 - 70:15] +// CHECK: load-stmts.cpp:70:3: DeclRefExpr=y:67:39 Extent=[70:3 - 70:4] +// CHECK: load-stmts.cpp:70:7: TypeRef=type:69:13 Extent=[70:7 - 70:11] +// CHECK: load-stmts.cpp:70:13: DeclRefExpr=t:67:34 Extent=[70:13 - 70:14] diff --git a/test/Index/local-symbols.m b/test/Index/local-symbols.m index 8557e7f..b9f4fe2 100644 --- a/test/Index/local-symbols.m +++ b/test/Index/local-symbols.m @@ -15,6 +15,17 @@ } @end +// From: <rdar://problem/8380046> + +@protocol Prot8380046 +@end + +@interface R8380046 +@end + +@interface R8380046 () <Prot8380046> +@end + // CHECK: local-symbols.m:6:12: ObjCInterfaceDecl=Foo:6:12 Extent=[6:1 - 10:5] // CHECK: local-symbols.m:7:6: ObjCIvarDecl=x:7:6 (Definition) Extent=[7:6 - 7:7] // CHECK: local-symbols.m:7:3: TypeRef=id:0:0 Extent=[7:3 - 7:5] @@ -23,4 +34,11 @@ // CHECK: local-symbols.m:12:1: ObjCImplementationDecl=Foo:12:1 (Definition) Extent=[12:1 - 16:2] // CHECK: local-symbols.m:13:1: ObjCInstanceMethodDecl=bar:13:1 (Definition) Extent=[13:1 - 15:2] // CHECK: local-symbols.m:13:4: TypeRef=id:0:0 Extent=[13:4 - 13:6] +// CHECK: local-symbols.m:14:10: UnexposedExpr= Extent=[14:10 - 14:11] +// CHECK: local-symbols.m:14:10: UnexposedExpr= Extent=[14:10 - 14:11] +// CHECK: local-symbols.m:20:1: ObjCProtocolDecl=Prot8380046:20:1 (Definition) Extent=[20:1 - 21:5] +// CHECK: local-symbols.m:23:12: ObjCInterfaceDecl=R8380046:23:12 Extent=[23:1 - 24:5] +// CHECK: local-symbols.m:26:12: ObjCCategoryDecl=:26:12 Extent=[26:1 - 27:5] +// CHECK: local-symbols.m:26:12: ObjCClassRef=R8380046:23:12 Extent=[26:12 - 26:20] +// CHECK: local-symbols.m:26:25: ObjCProtocolRef=Prot8380046:20:1 Extent=[26:25 - 26:36] diff --git a/test/Index/preamble-reparse.c b/test/Index/preamble-reparse.c new file mode 100644 index 0000000..5bd03b3f --- /dev/null +++ b/test/Index/preamble-reparse.c @@ -0,0 +1,2 @@ +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local "-remap-file=%S/Inputs/preamble-reparse-1.c;%S/Inputs/preamble-reparse-2.c" %S/Inputs/preamble-reparse-1.c | FileCheck %s +// CHECK: preamble-reparse-1.c:1:5: VarDecl=x:1:5 Extent=[1:1 - 1:6] diff --git a/test/Index/preamble.c b/test/Index/preamble.c new file mode 100644 index 0000000..54abf99 --- /dev/null +++ b/test/Index/preamble.c @@ -0,0 +1,28 @@ +#include "prefix.h" +#include "preamble.h" +int wibble(int); + +void f(int x) { + +} +// RUN: c-index-test -write-pch %t.pch -x c-header %S/Inputs/prefix.h +// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 local -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck %s +// RUN: FileCheck -check-prefix CHECK-DIAG %s < %t.stderr.txt +// CHECK: preamble.h:1:12: FunctionDecl=bar:1:12 (Definition) Extent=[1:12 - 6:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[1:23 - 6:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[2:3 - 2:16] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[3:3 - 3:15] +// CHECK: preamble.h:4:3: UnexposedExpr= Extent=[4:3 - 4:13] +// CHECK: preamble.h:4:3: DeclRefExpr=ptr:2:8 Extent=[4:3 - 4:6] +// CHECK: preamble.h:4:9: UnexposedExpr=ptr1:3:10 Extent=[4:9 - 4:13] +// CHECK: preamble.h:4:9: DeclRefExpr=ptr1:3:10 Extent=[4:9 - 4:13] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[5:3 - 5:11] +// CHECK: preamble.h:5:10: UnexposedExpr= Extent=[5:10 - 5:11] +// CHECK: preamble.c:3:5: FunctionDecl=wibble:3:5 Extent=[3:5 - 3:16] +// CHECK: preamble.c:3:15: ParmDecl=:3:15 (Definition) Extent=[3:12 - 3:16] +// CHECK-DIAG: preamble.h:4:7:{4:9-4:13}: warning: incompatible pointer types assigning to 'int *' from 'float *' +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:6:1 -I %S/Inputs -include %t %s 2> %t.stderr.txt | FileCheck -check-prefix CHECK-CC %s +// CHECK-CC: FunctionDecl:{ResultType int}{TypedText bar}{LeftParen (}{Placeholder int i}{RightParen )} (50) +// CHECK-CC: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder int x}{RightParen )} (45) +// CHECK-CC: FunctionDecl:{ResultType int}{TypedText foo}{LeftParen (}{Placeholder int}{RightParen )} (50) +// CHECK-CC: FunctionDecl:{ResultType int}{TypedText wibble}{LeftParen (}{Placeholder int}{RightParen )} (50) diff --git a/test/Index/print-typekind.c b/test/Index/print-typekind.c index 13b4119..18189c3 100644 --- a/test/Index/print-typekind.c +++ b/test/Index/print-typekind.c @@ -6,15 +6,20 @@ int *f(int *p, char *x, FooType z) { } // RUN: c-index-test -test-print-typekind %s | FileCheck %s -// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] -// CHECK: VarDecl=p:2:6 typekind=Pointer -// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] -// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer -// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer -// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] -// CHECK: VarDecl=w:4:11 (Definition) typekind=Typedef [canonical=Int] -// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] -// CHECK: UnexposedExpr= typekind=Pointer -// CHECK: DeclRefExpr=p:3:13 typekind=Pointer -// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] +// CHECK: TypedefDecl=FooType:1:13 (Definition) typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: VarDecl=p:2:6 typekind=Pointer [isPOD=1] +// CHECK: FunctionDecl=f:3:6 (Definition) typekind=FunctionProto [canonical=FunctionProto] [result=Pointer] [isPOD=0] +// CHECK: ParmDecl=p:3:13 (Definition) typekind=Pointer [isPOD=1] +// CHECK: ParmDecl=x:3:22 (Definition) typekind=Pointer [isPOD=1] +// CHECK: ParmDecl=z:3:33 (Definition) typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: TypeRef=FooType:1:13 typekind=Invalid [isPOD=0] +// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0] +// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0] +// CHECK: VarDecl=w:4:11 (Definition) typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: TypeRef=FooType:1:13 typekind=Invalid [isPOD=0] +// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1] +// CHECK: UnexposedStmt= typekind=Invalid [isPOD=0] +// CHECK: UnexposedExpr= typekind=Pointer [isPOD=1] +// CHECK: DeclRefExpr=p:3:13 typekind=Pointer [isPOD=1] +// CHECK: DeclRefExpr=z:3:33 typekind=Typedef [canonical=Int] [isPOD=1] diff --git a/test/Index/rdar-8288645-invalid-code.mm b/test/Index/rdar-8288645-invalid-code.mm new file mode 100644 index 0000000..3405f0a --- /dev/null +++ b/test/Index/rdar-8288645-invalid-code.mm @@ -0,0 +1,8 @@ +// RUN: c-index-test -test-load-source all %s 2>&1 | FileCheck %s + +// This test case previously crashed Sema. + +extern "C" { @implementation Foo - (id)initWithBar:(Baz<WozBar>)pepper { + +// CHECK: warning: cannot find interface declaration for 'Foo' +// CHECK: warning: '@end' is missing in implementation context diff --git a/test/Index/usrs.cpp b/test/Index/usrs.cpp index b6a6d3d..698aded 100644 --- a/test/Index/usrs.cpp +++ b/test/Index/usrs.cpp @@ -55,23 +55,35 @@ extern "C" { void rez(int a, int b); } +namespace foo_alias = foo; + +using namespace foo; + +namespace foo_alias2 = foo; + +using foo::ClsB; + +namespace foo_alias3 = foo; + // RUN: c-index-test -test-load-source-usrs all %s | FileCheck %s // CHECK: usrs.cpp c:@N@foo Extent=[1:11 - 4:2] // CHECK: usrs.cpp c:@N@foo@x Extent=[2:3 - 2:8] // CHECK: usrs.cpp c:@N@foo@F@bar#I# Extent=[3:8 - 3:18] -// CHECK: usrs.cpp c:usrs.cpp@3:12@N@foo@F@bar#I#@z Extent=[3:12 - 3:17] +// CHECK: usrs.cpp c:usrs.cpp@36@N@foo@F@bar#I#@z Extent=[3:12 - 3:17] // CHECK: usrs.cpp c:@N@bar Extent=[5:11 - 8:2] -// CHECK: usrs.cpp c:usrs.cpp@6:15@N@bar@T@QType Extent=[6:15 - 6:20] +// CHECK: usrs.cpp c:usrs.cpp@76@N@bar@T@QType Extent=[6:15 - 6:20] // CHECK: usrs.cpp c:@N@bar@F@bar#I# Extent=[7:8 - 7:20] -// CHECK: usrs.cpp c:usrs.cpp@7:12@N@bar@F@bar#I#@z Extent=[7:12 - 7:19] +// CHECK: usrs.cpp c:usrs.cpp@94@N@bar@F@bar#I#@z Extent=[7:12 - 7:19] // CHECK: usrs.cpp c:@C@ClsA Extent=[10:1 - 14:2] +// CHECK: usrs.cpp c: Extent=[11:1 - 11:8] // CHECK: usrs.cpp c:@C@ClsA@FI@a Extent=[12:7 - 12:8] // CHECK: usrs.cpp c:@C@ClsA@FI@b Extent=[12:10 - 12:11] // CHECK: usrs.cpp c:@C@ClsA@F@ClsA#I#I# Extent=[13:3 - 13:37] -// CHECK: usrs.cpp c:usrs.cpp@13:8@C@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13] -// CHECK: usrs.cpp c:usrs.cpp@13:15@C@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20] +// CHECK: usrs.cpp c:usrs.cpp@147@C@ClsA@F@ClsA#I#I#@A Extent=[13:8 - 13:13] +// CHECK: usrs.cpp c:usrs.cpp@154@C@ClsA@F@ClsA#I#I#@B Extent=[13:15 - 13:20] // CHECK: usrs.cpp c:@N@foo Extent=[16:11 - 22:2] // CHECK: usrs.cpp c:@N@foo@C@ClsB Extent=[17:3 - 21:4] +// CHECK: usrs.cpp c: Extent=[18:3 - 18:10] // CHECK: usrs.cpp c:@N@foo@C@ClsB@F@ClsB# Extent=[19:5 - 19:27] // CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[20:9 - 20:17] // CHECK: usrs.cpp c:@N@foo@C@ClsB@F@result#1 Extent=[24:16 - 26:2] @@ -81,27 +93,32 @@ extern "C" { // CHECK: usrs.cpp c:@N@foo Extent=[35:11 - 40:2] // CHECK: usrs.cpp c:@N@foo@N@taz Extent=[35:27 - 39:2] // CHECK: usrs.cpp c:@N@foo@N@taz@x Extent=[36:3 - 36:8] -// CHECK: usrs.cpp c:usrs.cpp@37:21@N@foo@N@taz@F@add#I#I# Extent=[37:21 - 37:56] -// CHECK: usrs.cpp c:usrs.cpp@37:25@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30] -// CHECK: usrs.cpp c:usrs.cpp@37:32@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37] +// CHECK: usrs.cpp c:usrs.cpp@475@N@foo@N@taz@F@add#I#I# Extent=[37:21 - 37:56] +// CHECK: usrs.cpp c:usrs.cpp@479@N@foo@N@taz@F@add#I#I#@a Extent=[37:25 - 37:30] +// CHECK: usrs.cpp c:usrs.cpp@486@N@foo@N@taz@F@add#I#I#@b Extent=[37:32 - 37:37] // CHECK: usrs.cpp c:@N@foo@N@taz@F@sub#I#I# Extent=[38:8 - 38:25] -// CHECK: usrs.cpp c:usrs.cpp@38:12@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17] -// CHECK: usrs.cpp c:usrs.cpp@38:19@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24] +// CHECK: usrs.cpp c:usrs.cpp@522@N@foo@N@taz@F@sub#I#I#@a Extent=[38:12 - 38:17] +// CHECK: usrs.cpp c:usrs.cpp@529@N@foo@N@taz@F@sub#I#I#@b Extent=[38:19 - 38:24] // CHECK: usrs.cpp c:@N@foo Extent=[42:11 - 52:3] // CHECK: usrs.cpp c:@N@foo@N@taz Extent=[42:27 - 52:2] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD Extent=[43:3 - 51:4] +// CHECK: usrs.cpp c: Extent=[44:3 - 44:10] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#I# Extent=[45:11 - 45:52] -// CHECK: usrs.cpp c:usrs.cpp@45:21@N@foo@N@taz@C@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26] +// CHECK: usrs.cpp c:usrs.cpp@638@N@foo@N@taz@C@ClsD@F@operator=#I#@x Extent=[45:21 - 45:26] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#d# Extent=[46:11 - 46:61] -// CHECK: usrs.cpp c:usrs.cpp@46:21@N@foo@N@taz@C@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29] +// CHECK: usrs.cpp c:usrs.cpp@690@N@foo@N@taz@C@ClsD@F@operator=#d#@x Extent=[46:21 - 46:29] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD# Extent=[47:11 - 47:62] -// CHECK: usrs.cpp c:usrs.cpp@47:27@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD#@x Extent=[47:27 - 47:34] +// CHECK: usrs.cpp c:usrs.cpp@757@N@foo@N@taz@C@ClsD@F@operator=#&1$@N@foo@N@taz@C@ClsD#@x Extent=[47:27 - 47:34] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@qux#S Extent=[48:16 - 48:21] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@uz#I.#S Extent=[49:16 - 49:30] -// CHECK: usrs.cpp c:usrs.cpp@49:19@N@foo@N@taz@C@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24] +// CHECK: usrs.cpp c:usrs.cpp@833@N@foo@N@taz@C@ClsD@F@uz#I.#S@z Extent=[49:19 - 49:24] // CHECK: usrs.cpp c:@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1 Extent=[50:10 - 50:62] -// CHECK: usrs.cpp c:usrs.cpp@50:27@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1@x Extent=[50:27 - 50:34] +// CHECK: usrs.cpp c:usrs.cpp@872@N@foo@N@taz@C@ClsD@F@operator==#&1$@N@foo@N@taz@C@ClsD#1@x Extent=[50:27 - 50:34] // CHECK: usrs.cpp c:@F@rez Extent=[55:8 - 55:25] -// CHECK: usrs.cpp c:usrs.cpp@55:12@F@rez@a Extent=[55:12 - 55:17] -// CHECK: usrs.cpp c:usrs.cpp@55:19@F@rez@b Extent=[55:19 - 55:24] - +// CHECK: usrs.cpp c:usrs.cpp@941@F@rez@a Extent=[55:12 - 55:17] +// CHECK: usrs.cpp c:usrs.cpp@948@F@rez@b Extent=[55:19 - 55:24] +// CHECK: usrs.cpp c:@NA@foo_alias +// CHECK-NOT: foo +// CHECK: usrs.cpp c:@NA@foo_alias2 +// CHECK-NOT: ClsB +// CHECK: usrs.cpp c:@NA@foo_alias3 diff --git a/test/Index/usrs.m b/test/Index/usrs.m index 0b56cca..4b3de5c 100644 --- a/test/Index/usrs.m +++ b/test/Index/usrs.m @@ -49,27 +49,39 @@ int z; static int local_func(int x) { return x; } @interface CWithExt +- (id) meth1; @end @interface CWithExt () +- (id) meth2; @end @interface CWithExt () +- (id) meth3; +@end +@interface CWithExt (Bar) +- (id) meth4; @end @implementation CWithExt +- (id) meth1 { return 0; } +- (id) meth2 { return 0; } +- (id) meth3 { return 0; } +@end +@implementation CWithExt (Bar) +- (id) meth4 { return 0; } @end -// CHECK: usrs.m c:usrs.m@3:19@F@my_helper Extent=[3:19 - 3:60] -// CHECK: usrs.m c:usrs.m@3:29@F@my_helper@x Extent=[3:29 - 3:34] -// CHECK: usrs.m c:usrs.m@3:36@F@my_helper@y Extent=[3:36 - 3:41] -// CHECK: usrs.m c:usrs.m@5:1@Ea Extent=[5:1 - 8:2] -// CHECK: usrs.m c:usrs.m@5:1@Ea@ABA Extent=[6:3 - 6:6] -// CHECK: usrs.m c:usrs.m@5:1@Ea@CADABA Extent=[7:3 - 7:9] -// CHECK: usrs.m c:usrs.m@10:1@Ea Extent=[10:1 - 13:2] -// CHECK: usrs.m c:usrs.m@10:1@Ea@FOO Extent=[11:3 - 11:6] -// CHECK: usrs.m c:usrs.m@10:1@Ea@BAR Extent=[12:3 - 12:6] +// CHECK: usrs.m c:usrs.m@85@F@my_helper Extent=[3:19 - 3:60] +// CHECK: usrs.m c:usrs.m@95@F@my_helper@x Extent=[3:29 - 3:34] +// CHECK: usrs.m c:usrs.m@102@F@my_helper@y Extent=[3:36 - 3:41] +// CHECK: usrs.m c:usrs.m@128@Ea Extent=[5:1 - 8:2] +// CHECK: usrs.m c:usrs.m@128@Ea@ABA Extent=[6:3 - 6:6] +// CHECK: usrs.m c:usrs.m@128@Ea@CADABA Extent=[7:3 - 7:9] +// CHECK: usrs.m c:usrs.m@155@Ea Extent=[10:1 - 13:2] +// CHECK: usrs.m c:usrs.m@155@Ea@FOO Extent=[11:3 - 11:6] +// CHECK: usrs.m c:usrs.m@155@Ea@BAR Extent=[12:3 - 12:6] // CHECK: usrs.m c:@SA@MyStruct Extent=[15:9 - 18:2] // CHECK: usrs.m c:@SA@MyStruct@FI@wa Extent=[16:7 - 16:9] // CHECK: usrs.m c:@SA@MyStruct@FI@moo Extent=[17:7 - 17:10] -// CHECK: usrs.m c:usrs.m@18:3@T@MyStruct Extent=[18:3 - 18:11] +// CHECK: usrs.m c:usrs.m@219@T@MyStruct Extent=[18:3 - 18:11] // CHECK: usrs.m c:@E@Pizza Extent=[20:1 - 23:2] // CHECK: usrs.m c:@E@Pizza@CHEESE Extent=[21:3 - 21:9] // CHECK: usrs.m c:@E@Pizza@MUSHROOMS Extent=[22:3 - 22:12] @@ -81,21 +93,30 @@ static int local_func(int x) { return x; } // CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[30:1 - 30:17] // CHECK: usrs.m c:objc(cs)Foo(im)d1 Extent=[31:15 - 31:17] // CHECK: usrs.m c:objc(cs)Foo(im)setD1: Extent=[31:15 - 31:17] -// CHECK: usrs.m c:usrs.m@31:15objc(cs)Foo(im)setD1:@d1 Extent=[31:15 - 31:17] +// CHECK: usrs.m c:usrs.m@352objc(cs)Foo(im)setD1:@d1 Extent=[31:15 - 31:17] // CHECK: usrs.m c:objc(cs)Foo Extent=[34:1 - 45:2] // CHECK: usrs.m c:objc(cs)Foo(im)godzilla Extent=[35:1 - 39:2] -// CHECK: usrs.m c:usrs.m@36:10objc(cs)Foo(im)godzilla@a Extent=[36:10 - 36:19] +// CHECK: usrs.m c:usrs.m@409objc(cs)Foo(im)godzilla@a Extent=[36:10 - 36:19] // CHECK: usrs.m c:objc(cs)Foo(im)godzilla@z Extent=[37:10 - 37:15] // CHECK: usrs.m c:objc(cs)Foo(cm)kingkong Extent=[40:1 - 43:2] -// CHECK: usrs.m c:usrs.m@41:3objc(cs)Foo(cm)kingkong@local_var Extent=[41:3 - 41:16] +// CHECK: usrs.m c:usrs.m@470objc(cs)Foo(cm)kingkong@local_var Extent=[41:3 - 41:16] // CHECK: usrs.m c:objc(cs)Foo@d1 Extent=[44:13 - 44:15] // CHECK: usrs.m c:objc(cs)Foo(py)d1 Extent=[44:1 - 44:15] // CHECK: usrs.m c:@z Extent=[47:1 - 47:6] -// CHECK: usrs.m c:usrs.m@49:12@F@local_func Extent=[49:12 - 49:43] -// CHECK: usrs.m c:usrs.m@49:23@F@local_func@x Extent=[49:23 - 49:28] -// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 52:5] -// CHECK: usrs.m c:objc(cy)CWithExt@ Extent=[53:1 - 54:5] -// CHECK: usrs.m c:objc(cy)CWithExt@ Extent=[55:1 - 56:5] -// CHECK: usrs.m c:objc(cs)CWithExt Extent=[57:1 - 58:2] - +// CHECK: usrs.m c:usrs.m@540@F@local_func Extent=[49:12 - 49:43] +// CHECK: usrs.m c:usrs.m@551@F@local_func@x Extent=[49:23 - 49:28] +// CHECK: usrs.m c:objc(cs)CWithExt Extent=[51:1 - 53:5] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[52:1 - 52:14] +// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@612 Extent=[54:1 - 56:5] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[55:1 - 55:14] +// CHECK: usrs.m c:objc(ext)CWithExt@usrs.m@654 Extent=[57:1 - 59:5] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[58:1 - 58:14] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[60:1 - 62:5] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar(im)meth4 Extent=[61:1 - 61:14] +// CHECK: usrs.m c:objc(cs)CWithExt Extent=[63:1 - 67:2] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth1 Extent=[64:1 - 64:27] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth2 Extent=[65:1 - 65:27] +// CHECK: usrs.m c:objc(cs)CWithExt(im)meth3 Extent=[66:1 - 66:27] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar Extent=[68:1 - 70:2] +// CHECK: usrs.m c:objc(cy)CWithExt@Bar(im)meth4 Extent=[69:1 - 69:27] |