diff options
-rw-r--r-- | test/Index/annotate-tokens.m | 142 | ||||
-rw-r--r-- | test/Index/c-index-api-loadTU-test.m | 16 | ||||
-rw-r--r-- | test/Index/load-stmts.cpp | 41 | ||||
-rw-r--r-- | test/Index/remap-load.c | 4 | ||||
-rw-r--r-- | tools/libclang/CIndex.cpp | 4 |
5 files changed, 184 insertions, 23 deletions
diff --git a/test/Index/annotate-tokens.m b/test/Index/annotate-tokens.m index 8e6d977091..bcbbd0edd0 100644 --- a/test/Index/annotate-tokens.m +++ b/test/Index/annotate-tokens.m @@ -25,7 +25,38 @@ typedef int * barType; } @end -// RUN: c-index-test -test-annotate-tokens=%s:1:1:27:1 %s | FileCheck %s +// From <rdar://problem/7967123>. The ranges for attributes are not +// currently stored, causing most of the tokens to be falsely annotated. +// Since there are no source ranges for attributes, we currently don't +// annotate them. +@interface IBActionTests +- (IBAction) actionMethod:(id)arg; +- (void)foo:(int)x; +@end +extern int ibaction_test(void); +@implementation IBActionTests +- (IBAction) actionMethod:(id)arg +{ + ibaction_test(); + [self foo:0]; +} +- (void) foo:(int)x +{ + (void) x; +} +@end + +// From <rdar://problem/7961995>. Essentially the same issue as 7967123, +// but impacting code marked as IBOutlets. +@interface IBOutletTests +{ + IBOutlet char * anOutlet; +} +- (IBAction) actionMethod:(id)arg; +@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 // 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 @@ -110,4 +141,113 @@ typedef int * barType; // CHECK: Punctuation: "}" [25:1 - 25:2] UnexposedStmt= // CHECK: Punctuation: "@" [26:1 - 26:2] ObjCImplementationDecl=Bar:21:1 (Definition) // CHECK: Keyword: "end" [26:2 - 26:5] +// CHECK: Punctuation: "@" [32:1 - 32:2] ObjCInterfaceDecl=IBActionTests:32:12 +// CHECK: Keyword: "interface" [32:2 - 32:11] ObjCInterfaceDecl=IBActionTests:32:12 +// CHECK: Identifier: "IBActionTests" [32:12 - 32:25] ObjCInterfaceDecl=IBActionTests:32:12 +// CHECK: Punctuation: "-" [33:1 - 33:2] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Punctuation: "(" [33:3 - 33:4] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Identifier: "IBAction" [33:4 - 33:12] macro instantiation=IBAction:131:9 +// CHECK: Punctuation: ")" [33:12 - 33:13] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Identifier: "actionMethod" [33:14 - 33:26] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Punctuation: ":" [33:26 - 33:27] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Punctuation: "(" [33:27 - 33:28] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Identifier: "id" [33:28 - 33:30] TypeRef=id:0:0 +// CHECK: Punctuation: ")" [33:30 - 33:31] ParmDecl=arg:33:31 (Definition) +// CHECK: Identifier: "arg" [33:31 - 33:34] ParmDecl=arg:33:31 (Definition) +// CHECK: Punctuation: ";" [33:34 - 33:35] ObjCInstanceMethodDecl=actionMethod::33:1 +// CHECK: Punctuation: "-" [34:1 - 34:2] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Punctuation: "(" [34:3 - 34:4] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Keyword: "void" [34:4 - 34:8] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Punctuation: ")" [34:8 - 34:9] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Identifier: "foo" [34:9 - 34:12] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Punctuation: ":" [34:12 - 34:13] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Punctuation: "(" [34:13 - 34:14] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Keyword: "int" [34:14 - 34:17] ParmDecl=x:34:18 (Definition) +// CHECK: Punctuation: ")" [34:17 - 34:18] ParmDecl=x:34:18 (Definition) +// CHECK: Identifier: "x" [34:18 - 34:19] ParmDecl=x:34:18 (Definition) +// CHECK: Punctuation: ";" [34:19 - 34:20] ObjCInstanceMethodDecl=foo::34:1 +// CHECK: Punctuation: "@" [35:1 - 35:2] ObjCInterfaceDecl=IBActionTests:32:12 +// CHECK: Keyword: "end" [35:2 - 35:5] ObjCInterfaceDecl=IBActionTests:32:12 +// CHECK: Keyword: "extern" [36:1 - 36:7] +// CHECK: Keyword: "int" [36:8 - 36:11] FunctionDecl=ibaction_test:36:12 +// CHECK: Identifier: "ibaction_test" [36:12 - 36:25] FunctionDecl=ibaction_test:36:12 +// CHECK: Punctuation: "(" [36:25 - 36:26] FunctionDecl=ibaction_test:36:12 +// CHECK: Keyword: "void" [36:26 - 36:30] FunctionDecl=ibaction_test:36:12 +// CHECK: Punctuation: ")" [36:30 - 36:31] FunctionDecl=ibaction_test:36:12 +// CHECK: Punctuation: ";" [36:31 - 36:32] +// CHECK: Punctuation: "@" [37:1 - 37:2] ObjCImplementationDecl=IBActionTests:37:1 (Definition) +// CHECK: Keyword: "implementation" [37:2 - 37:16] ObjCImplementationDecl=IBActionTests:37:1 (Definition) +// CHECK: Identifier: "IBActionTests" [37:17 - 37:30] ObjCImplementationDecl=IBActionTests:37:1 (Definition) +// CHECK: Punctuation: "-" [38:1 - 38:2] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) +// CHECK: Punctuation: "(" [38:3 - 38:4] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) +// CHECK: Identifier: "IBAction" [38:4 - 38:12] macro instantiation=IBAction:131:9 +// CHECK: Punctuation: ")" [38:12 - 38:13] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) +// CHECK: Identifier: "actionMethod" [38:14 - 38:26] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) +// CHECK: Punctuation: ":" [38:26 - 38:27] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) +// CHECK: Punctuation: "(" [38:27 - 38:28] ObjCInstanceMethodDecl=actionMethod::38:1 (Definition) +// CHECK: Identifier: "id" [38:28 - 38:30] TypeRef=id:0:0 +// CHECK: Punctuation: ")" [38:30 - 38:31] ParmDecl=arg:38:31 (Definition) +// CHECK: Identifier: "arg" [38:31 - 38:34] ParmDecl=arg:38:31 (Definition) +// CHECK: Punctuation: "{" [39:1 - 39:2] UnexposedStmt= +// CHECK: Identifier: "ibaction_test" [40:5 - 40:18] DeclRefExpr=ibaction_test:36:12 +// CHECK: Punctuation: "(" [40:18 - 40:19] CallExpr=ibaction_test:36:12 +// CHECK: Punctuation: ")" [40:19 - 40:20] CallExpr=ibaction_test:36:12 +// CHECK: Punctuation: ";" [40:20 - 40:21] UnexposedStmt= +// CHECK: Punctuation: "[" [41:5 - 41:6] ObjCMessageExpr=foo::34:1 +// CHECK: Identifier: "self" [41:6 - 41:10] DeclRefExpr=self:0:0 +// CHECK: Identifier: "foo" [41:11 - 41:14] ObjCMessageExpr=foo::34:1 +// CHECK: Punctuation: ":" [41:14 - 41:15] ObjCMessageExpr=foo::34:1 +// CHECK: Literal: "0" [41:15 - 41:16] UnexposedExpr= +// CHECK: Punctuation: "]" [41:16 - 41:17] ObjCMessageExpr=foo::34:1 +// CHECK: Punctuation: ";" [41:17 - 41:18] UnexposedStmt= +// CHECK: Punctuation: "}" [42:1 - 42:2] UnexposedStmt= +// CHECK: Punctuation: "-" [43:1 - 43:2] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Punctuation: "(" [43:3 - 43:4] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Keyword: "void" [43:4 - 43:8] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Punctuation: ")" [43:8 - 43:9] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Identifier: "foo" [43:10 - 43:13] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Punctuation: ":" [43:13 - 43:14] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Punctuation: "(" [43:14 - 43:15] ObjCInstanceMethodDecl=foo::43:1 (Definition) +// CHECK: Keyword: "int" [43:15 - 43:18] ParmDecl=x:43:19 (Definition) +// CHECK: Punctuation: ")" [43:18 - 43:19] ParmDecl=x:43:19 (Definition) +// CHECK: Identifier: "x" [43:19 - 43:20] ParmDecl=x:43:19 (Definition) +// CHECK: Punctuation: "{" [44:1 - 44:2] UnexposedStmt= +// CHECK: Punctuation: "(" [45:3 - 45:4] UnexposedExpr=x:43:19 +// CHECK: Keyword: "void" [45:4 - 45:8] UnexposedExpr=x:43:19 +// CHECK: Punctuation: ")" [45:8 - 45:9] UnexposedExpr=x:43:19 +// CHECK: Identifier: "x" [45:10 - 45:11] DeclRefExpr=x:43:19 +// CHECK: Punctuation: ";" [45:11 - 45:12] UnexposedStmt= +// CHECK: Punctuation: "}" [46:1 - 46:2] UnexposedStmt= +// CHECK: Punctuation: "@" [47:1 - 47:2] ObjCImplementationDecl=IBActionTests:37:1 (Definition) +// CHECK: Keyword: "end" [47:2 - 47:5] +// CHECK: Punctuation: "@" [51:1 - 51:2] ObjCInterfaceDecl=IBOutletTests:51:12 +// 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:132:9 +// 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) +// CHECK: Punctuation: ";" [53:29 - 53:30] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Punctuation: "}" [54:1 - 54:2] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Punctuation: "-" [55:1 - 55:2] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Punctuation: "(" [55:3 - 55:4] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Identifier: "IBAction" [55:4 - 55:12] macro instantiation=IBAction:131:9 +// CHECK: Punctuation: ")" [55:12 - 55:13] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Identifier: "actionMethod" [55:14 - 55:26] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Punctuation: ":" [55:26 - 55:27] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Punctuation: "(" [55:27 - 55:28] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Identifier: "id" [55:28 - 55:30] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Punctuation: ")" [55:30 - 55:31] ObjCInterfaceDecl=IBOutletTests:51:12 +// CHECK: Identifier: "arg" [55:31 - 55:34] ObjCInterfaceDecl=IBOutletTests:51:12 +// 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:132:9 +// 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 diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 5b2f86e543..d97f963a3a 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -56,10 +56,10 @@ int main (int argc, const char * argv[]) { // CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:12 Extent=[4:1 - 12:5] // CHECK: c-index-api-loadTU-test.m:6:32: ObjCIvarDecl=myoutlet:6:32 (Definition) Extent=[6:32 - 6:40] -// CHECK: c-index-api-loadTU-test.m:6:32: attribute(iboutlet)= Extent=[6:32 - 6:40] +// CHECK: <invalid loc>:0:0: attribute(iboutlet)= // CHECK: c-index-api-loadTU-test.m:6:29: TypeRef=id:0:0 Extent=[6:29 - 6:31] // CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=myMessage::8:1 Extent=[8:1 - 8:54] -// CHECK: c-index-api-loadTU-test.m:8:1: attribute(ibaction)= Extent=[8:1 - 8:54] +// 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] @@ -81,27 +81,29 @@ int main (int argc, const char * argv[]) { // CHECK: c-index-api-loadTU-test.m:33:23: ObjCProtocolRef=SubP:29:1 Extent=[33:23 - 33:27] // CHECK: c-index-api-loadTU-test.m:35:9: ObjCIvarDecl=_anIVar:35:9 (Definition) Extent=[35:9 - 35:16] // CHECK: c-index-api-loadTU-test.m:38:1: ObjCInstanceMethodDecl=bazMethod:38:1 Extent=[38:1 - 38:21] +// CHECK: c-index-api-loadTU-test.m:38:4: ObjCClassRef=Foo:4:12 Extent=[38:4 - 38:7] // CHECK: c-index-api-loadTU-test.m:42:1: EnumDecl=:42:1 (Definition) Extent=[42:1 - 44:2] // CHECK: c-index-api-loadTU-test.m:43:3: EnumConstantDecl=someEnum:43:3 (Definition) Extent=[43:3 - 43:11] // CHECK: c-index-api-loadTU-test.m:46:5: FunctionDecl=main:46:5 (Definition) Extent=[46:5 - 55:2] // CHECK: c-index-api-loadTU-test.m:46:15: ParmDecl=argc:46:15 (Definition) Extent=[46:11 - 46:19] // CHECK: c-index-api-loadTU-test.m:46:34: ParmDecl=argv:46:34 (Definition) Extent=[46:27 - 46:38] -// CHECK: c-index-api-loadTU-test.m:46:5: UnexposedStmt= Extent=[46:42 - 55:2] -// CHECK: c-index-api-loadTU-test.m:46:5: UnexposedStmt= Extent=[47:2 - 47:12] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[46:42 - 55:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[47:2 - 47:12] // CHECK: c-index-api-loadTU-test.m:47:8: VarDecl=bee:47:8 (Definition) Extent=[47:2 - 47:11] // CHECK: c-index-api-loadTU-test.m:47:2: ObjCClassRef=Baz:33:12 Extent=[47:2 - 47:5] -// CHECK: c-index-api-loadTU-test.m:47:8: UnexposedStmt= Extent=[48:2 - 48:19] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[48:2 - 48:19] // CHECK: c-index-api-loadTU-test.m:48:5: VarDecl=a:48:5 (Definition) Extent=[48:2 - 48:18] // CHECK: c-index-api-loadTU-test.m:48:2: TypeRef=id:0:0 Extent=[48:2 - 48:4] // CHECK: c-index-api-loadTU-test.m:48:9: ObjCMessageExpr=foo:9:1 Extent=[48:9 - 48:18] // CHECK: c-index-api-loadTU-test.m:48:10: DeclRefExpr=bee:47:8 Extent=[48:10 - 48:13] -// CHECK: c-index-api-loadTU-test.m:48:5: UnexposedStmt= Extent=[49:2 - 49:27] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[49:2 - 49:27] // CHECK: c-index-api-loadTU-test.m:49:12: VarDecl=c:49:12 (Definition) Extent=[49:2 - 49:26] // CHECK: c-index-api-loadTU-test.m:49:2: TypeRef=id:0:0 Extent=[49:2 - 49:4] // CHECK: c-index-api-loadTU-test.m:49:6: ObjCProtocolRef=SubP:29:1 Extent=[49:6 - 49:10] // CHECK: c-index-api-loadTU-test.m:49:16: UnexposedExpr=fooC:10:1 Extent=[49:16 - 49:26] // CHECK: c-index-api-loadTU-test.m:49:16: ObjCMessageExpr=fooC:10:1 Extent=[49:16 - 49:26] -// CHECK: c-index-api-loadTU-test.m:49:12: UnexposedStmt= Extent=[50:2 - 50:15] +// CHECK: c-index-api-loadTU-test.m:49:17: ObjCClassRef=Foo:4:12 Extent=[49:17 - 49:20] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[50:2 - 50:15] // CHECK: c-index-api-loadTU-test.m:50:13: VarDecl=d:50:13 (Definition) Extent=[50:2 - 50:14] // CHECK: c-index-api-loadTU-test.m:50:2: TypeRef=id:0:0 Extent=[50:2 - 50:4] // CHECK: c-index-api-loadTU-test.m:50:6: ObjCProtocolRef=Proto:25:1 Extent=[50:6 - 50:11] diff --git a/test/Index/load-stmts.cpp b/test/Index/load-stmts.cpp index fdfedfb16e..5a0f43117b 100644 --- a/test/Index/load-stmts.cpp +++ b/test/Index/load-stmts.cpp @@ -11,8 +11,26 @@ void f(int x) { } // RUN: c-index-test -test-load-source all %s | FileCheck %s -// CHECK: load-stmts.cpp:3:6: UnexposedStmt= Extent=[4:3 - 5:4] -// CHECK: load-stmts.cpp:3:6: UnexposedStmt= Extent=[4:8 - 4:16] +// CHECK: <invalid loc>:0:0: TypedefDecl=__int128_t:0:0 (Definition) +// CHECK: <invalid loc>:0:0: TypedefDecl=__uint128_t:0:0 (Definition) +// CHECK: <invalid loc>:91:16: StructDecl=__va_list_tag:91:16 (Definition) +// CHECK: <invalid loc>:91:42: FieldDecl=gp_offset:91:42 (Definition) +// CHECK: <invalid loc>:91:63: FieldDecl=fp_offset:91:63 (Definition) +// CHECK: <invalid loc>:91:81: FieldDecl=overflow_arg_area:91:81 (Definition) +// CHECK: <invalid loc>:91:107: FieldDecl=reg_save_area:91:107 (Definition) +// CHECK: <invalid loc>:91:123: TypedefDecl=__va_list_tag:91:123 (Definition) +// CHECK: <invalid loc>:91:159: TypedefDecl=__builtin_va_list:91:159 (Definition) +// CHECK: <invalid loc>:91:145: TypeRef=__va_list_tag:91:123 +// CHECK: <invalid loc>:91:177: UnexposedExpr= +// 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] +// CHECK: load-stmts.cpp:2:16: FieldDecl=a:2:16 (Definition) Extent=[2:16 - 2:17] +// CHECK: load-stmts.cpp:2:19: FieldDecl=b:2:19 (Definition) Extent=[2:19 - 2:20] +// CHECK: load-stmts.cpp:3:6: FunctionDecl=f:3:6 (Definition) Extent=[3:6 - 11:2] +// CHECK: load-stmts.cpp:3:12: ParmDecl=x:3:12 (Definition) Extent=[3:8 - 3:13] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[3:15 - 11:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[4:3 - 5:4] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[4:8 - 4:16] // CHECK: load-stmts.cpp:4:10: VarDecl=y:4:10 (Definition) Extent=[4:8 - 4:15] // CHECK: load-stmts.cpp:4:8: TypeRef=T:1:13 Extent=[4:8 - 4:9] // CHECK: load-stmts.cpp:4:14: DeclRefExpr=x:3:12 Extent=[4:14 - 4:15] @@ -23,29 +41,30 @@ void f(int x) { // CHECK: load-stmts.cpp:4:19: DeclRefExpr=z:4:19 Extent=[4:19 - 4:20] // CHECK: load-stmts.cpp:4:26: UnexposedExpr= Extent=[4:26 - 4:29] // CHECK: load-stmts.cpp:4:28: DeclRefExpr=x:3:12 Extent=[4:28 - 4:29] -// CHECK: load-stmts.cpp:4:19: UnexposedStmt= Extent=[4:31 - 5:4] -// CHECK: load-stmts.cpp:4:19: UnexposedStmt= Extent=[6:3 - 6:22] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[4:31 - 5:4] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[6:3 - 6:22] // CHECK: load-stmts.cpp:6:10: VarDecl=z2:6:10 (Definition) Extent=[6:7 - 6:17] // CHECK: load-stmts.cpp:6:7: TypeRef=T:1:13 Extent=[6:7 - 6:8] // CHECK: load-stmts.cpp:6:15: UnexposedExpr= Extent=[6:15 - 6:17] // CHECK: load-stmts.cpp:6:16: DeclRefExpr=x:3:12 Extent=[6:16 - 6:17] // CHECK: load-stmts.cpp:6:10: UnexposedExpr=z2:6:10 Extent=[6:10 - 6:12] // CHECK: load-stmts.cpp:6:10: DeclRefExpr=z2:6:10 Extent=[6:10 - 6:12] -// CHECK: load-stmts.cpp:6:10: UnexposedStmt= Extent=[6:19 - 6:22] -// CHECK: load-stmts.cpp:6:10: UnexposedStmt= Extent=[7:3 - 7:25] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[6:19 - 6:22] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[7:3 - 7:25] // CHECK: load-stmts.cpp:7:13: VarDecl=z3:7:13 (Definition) Extent=[7:10 - 7:20] // CHECK: load-stmts.cpp:7:10: TypeRef=T:1:13 Extent=[7:10 - 7:11] // CHECK: load-stmts.cpp:7:18: UnexposedExpr= Extent=[7:18 - 7:20] // CHECK: load-stmts.cpp:7:19: DeclRefExpr=x:3:12 Extent=[7:19 - 7:20] // CHECK: load-stmts.cpp:7:13: UnexposedExpr=z3:7:13 Extent=[7:13 - 7:15] // CHECK: load-stmts.cpp:7:13: DeclRefExpr=z3:7:13 Extent=[7:13 - 7:15] -// CHECK: load-stmts.cpp:7:13: UnexposedStmt= Extent=[7:22 - 7:25] -// CHECK: load-stmts.cpp:7:13: UnexposedStmt= Extent=[8:3 - 10:4] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[7:22 - 7:25] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[8:3 - 10:4] // CHECK: load-stmts.cpp:8:13: VarDecl=z4:8:13 (Definition) Extent=[8:11 - 8:19] // CHECK: load-stmts.cpp:8:11: TypeRef=T:1:13 Extent=[8:11 - 8:12] // CHECK: load-stmts.cpp:8:18: DeclRefExpr=x:3:12 Extent=[8:18 - 8:19] // CHECK: load-stmts.cpp:8:13: DeclRefExpr=z4:8:13 Extent=[8:13 - 8:15] -// CHECK: load-stmts.cpp:8:13: UnexposedStmt= Extent=[8:21 - 10:4] -// CHECK: load-stmts.cpp:8:13: UnexposedStmt= Extent=[9:3 - 9:17] -// CHECK: load-stmts.cpp:8:13: UnexposedStmt= Extent=[9:12 - 9:17] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[8:21 - 10:4] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:3 - 9:17] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[9:12 - 9:17] // CHECK: load-stmts.cpp:9:8: UnexposedExpr= Extent=[9:8 - 9:10] + diff --git a/test/Index/remap-load.c b/test/Index/remap-load.c index b8415e6a17..d9634a4af6 100644 --- a/test/Index/remap-load.c +++ b/test/Index/remap-load.c @@ -5,8 +5,8 @@ // CHECK: remap-load.c:1:5: FunctionDecl=foo:1:5 (Definition) Extent=[1:5 - 3:2] // CHECK: remap-load.c:1:13: ParmDecl=parm1:1:13 (Definition) Extent=[1:9 - 1:18] // CHECK: remap-load.c:1:26: ParmDecl=parm2:1:26 (Definition) Extent=[1:20 - 1:31] -// CHECK: remap-load.c:1:5: UnexposedStmt= Extent=[1:33 - 3:2] -// CHECK: remap-load.c:1:5: UnexposedStmt= Extent=[2:3 - 2:23] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[1:33 - 3:2] +// CHECK: <invalid loc>:0:0: UnexposedStmt= Extent=[2:3 - 2:23] // CHECK: remap-load.c:2:10: UnexposedExpr= Extent=[2:10 - 2:23] // CHECK: remap-load.c:2:10: UnexposedExpr= Extent=[2:10 - 2:23] // CHECK: remap-load.c:2:10: UnexposedExpr=parm1:1:13 Extent=[2:10 - 2:15] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index d24652b22d..7f227a01eb 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1794,7 +1794,7 @@ CXSourceLocation clang_getCursorLocation(CXCursor C) { return cxloc::translateSourceLocation(getCursorContext(C), L); } - if (!getCursorDecl(C)) + if (C.kind < CXCursor_FirstDecl || C.kind > CXCursor_LastDecl) return clang_getNullLocation(); Decl *D = getCursorDecl(C); @@ -1860,7 +1860,7 @@ CXSourceRange clang_getCursorExtent(CXCursor C) { return cxloc::translateSourceRange(getCursorContext(C), R); } - if (!getCursorDecl(C)) + if (C.kind < CXCursor_FirstDecl || C.kind > CXCursor_LastDecl) return clang_getNullRange(); Decl *D = getCursorDecl(C); |