diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-01-18 20:23:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-01-18 20:23:29 +0000 |
commit | cf84aa46def41cccf4dd4c51cd0543b70c11e4eb (patch) | |
tree | 97cf0e8db09f9114f5dee32b9425ea953d7f6690 | |
parent | 42f56b50062cd3b3c6b23fdb9053578ae9145664 (diff) |
Replace clang_getDeclUSR() with clang_getCursorUSR(). Also remove printing 'contexts' from c-index-test output; it wasn't helpful and was extremely brittle.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93760 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang-c/Index.h | 5 | ||||
-rw-r--r-- | test/Index/TestClassDecl.m | 6 | ||||
-rw-r--r-- | test/Index/TestClassForwardDecl.m | 4 | ||||
-rw-r--r-- | test/Index/c-index-api-fn-scan.m | 248 | ||||
-rw-r--r-- | test/Index/c-index-api-loadTU-test.m | 56 | ||||
-rw-r--r-- | test/Index/cindex-from-source.m | 4 | ||||
-rw-r--r-- | tools/CIndex/CIndex.exports | 4 | ||||
-rw-r--r-- | tools/CIndex/CIndexUSRs.cpp | 41 | ||||
-rw-r--r-- | tools/c-index-test/c-index-test.c | 22 |
9 files changed, 194 insertions, 196 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 4c9f3a36d0..c7b0a5197c 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -336,7 +336,6 @@ CINDEX_LINKAGE CXEntity clang_getEntityFromDecl(CXIndex, CXDecl); CINDEX_LINKAGE CXString clang_getDeclSpelling(CXDecl); CINDEX_LINKAGE unsigned clang_getDeclLine(CXDecl); CINDEX_LINKAGE unsigned clang_getDeclColumn(CXDecl); -CINDEX_LINKAGE CXString clang_getDeclUSR(CXDecl); CINDEX_LINKAGE const char *clang_getDeclSource(CXDecl); /* deprecate */ CINDEX_LINKAGE CXFile clang_getDeclSourceFile(CXDecl); @@ -370,6 +369,10 @@ CINDEX_LINKAGE CXCursor clang_getCursor(CXTranslationUnit, CINDEX_LINKAGE CXCursor clang_getNullCursor(void); +/* clang_getCursorUSR() returns the USR (if any) associated with entity referred to by the + * provided CXCursor object. */ +CINDEX_LINKAGE CXString clang_getCursorUSR(CXCursor); + CINDEX_LINKAGE enum CXCursorKind clang_getCursorKind(CXCursor); CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind); CINDEX_LINKAGE unsigned clang_isReference(enum CXCursorKind); diff --git a/test/Index/TestClassDecl.m b/test/Index/TestClassDecl.m index 9737ec213f..20431ca23f 100644 --- a/test/Index/TestClassDecl.m +++ b/test/Index/TestClassDecl.m @@ -32,7 +32,7 @@ void function(Foo * arg) // CHECK-scan: {start_line=13 start_col=24 end_line=16 end_col=1} FunctionDefn=function:13:6 // CHECK-scan: {start_line=16 start_col=2 end_line=38 end_col=1} Invalid Cursor => NoDeclFound -// CHECK-load: TestClassDecl.m:10:12: ObjCInterfaceDecl=Foo:10:1 [Context=TestClassDecl.m] [Extent=10:1:11:4] -// CHECK-load: TestClassDecl.m:13:6: FunctionDefn=function:13:6 [Context=TestClassDecl.m] [Extent=13:6:16:1] -// CHECK-load: TestClassDecl.m:13:21: ParmDecl=arg:13:21 [Context=function] [Extent=13:21:13:23] +// CHECK-load: TestClassDecl.m:10:12: ObjCInterfaceDecl=Foo:10:1 [Extent=10:1:11:4] +// CHECK-load: TestClassDecl.m:13:6: FunctionDefn=function:13:6 [Extent=13:6:16:1] +// CHECK-load: TestClassDecl.m:13:21: ParmDecl=arg:13:21 [Extent=13:21:13:23] diff --git a/test/Index/TestClassForwardDecl.m b/test/Index/TestClassForwardDecl.m index 76c0b6cffa..c9d9831d51 100644 --- a/test/Index/TestClassForwardDecl.m +++ b/test/Index/TestClassForwardDecl.m @@ -41,6 +41,6 @@ void function(Foo * arg) -// CHECK-load: TestClassForwardDecl.m:10:6: FunctionDefn=function:10:6 [Context=TestClassForwardDecl.m] -// CHECK-load: TestClassForwardDecl.m:10:21: ParmDecl=arg:10:21 [Context=function] +// CHECK-load: TestClassForwardDecl.m:10:6: FunctionDefn=function:10:6 +// CHECK-load: TestClassForwardDecl.m:10:21: ParmDecl=arg:10:21 diff --git a/test/Index/c-index-api-fn-scan.m b/test/Index/c-index-api-fn-scan.m index b0728ec90b..07fbcc6143 100644 --- a/test/Index/c-index-api-fn-scan.m +++ b/test/Index/c-index-api-fn-scan.m @@ -91,127 +91,127 @@ int main (int argc, const char * argv[]) { main(someEnum, (const char **)bee); } -// CHECK: c-index-api-fn-scan.m:84:2: ObjCClassRef=Baz:48:1 [Context:Baz] -// CHECK: c-index-api-fn-scan.m:84:3: ObjCClassRef=Baz:48:1 [Context:Baz] -// CHECK: c-index-api-fn-scan.m:84:4: ObjCClassRef=Baz:48:1 [Context:Baz] -// CHECK: c-index-api-fn-scan.m:84:6: VarDecl=bee:84:8 [Context:bee] -// CHECK: c-index-api-fn-scan.m:84:8: VarDecl=bee:84:8 [Context:bee] -// CHECK: c-index-api-fn-scan.m:84:9: VarDecl=bee:84:8 [Context:bee] -// CHECK: c-index-api-fn-scan.m:84:10: VarDecl=bee:84:8 [Context:bee] -// CHECK: <invalid loc>:85:2: TypedefDecl=id:0:0 [Context:id] -// CHECK: <invalid loc>:85:3: TypedefDecl=id:0:0 [Context:id] -// CHECK: c-index-api-fn-scan.m:85:5: VarDecl=a:85:5 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:6: VarDecl=a:85:5 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:7: VarDecl=a:85:5 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:8: VarDecl=a:85:5 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:9: ObjCSelectorRef=foo:24:1 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:10: VarRef=bee:84:8 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:11: VarRef=bee:84:8 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:12: VarRef=bee:84:8 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:13: ObjCSelectorRef=foo:24:1 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:14: ObjCSelectorRef=foo:24:1 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:15: ObjCSelectorRef=foo:24:1 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:16: ObjCSelectorRef=foo:24:1 [Context:a] -// CHECK: c-index-api-fn-scan.m:85:17: ObjCSelectorRef=foo:24:1 [Context:a] -// CHECK: <invalid loc>:86:2: TypedefDecl=id:0:0 [Context:id] -// CHECK: <invalid loc>:86:3: TypedefDecl=id:0:0 [Context:id] -// CHECK: c-index-api-fn-scan.m:86:5: VarDecl=c:86:12 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:6: ObjCProtocolRef=SubP:44:1 [Context:SubP] -// CHECK: c-index-api-fn-scan.m:86:7: ObjCProtocolRef=SubP:44:1 [Context:SubP] -// CHECK: c-index-api-fn-scan.m:86:8: ObjCProtocolRef=SubP:44:1 [Context:SubP] -// CHECK: c-index-api-fn-scan.m:86:9: ObjCProtocolRef=SubP:44:1 [Context:SubP] -// CHECK: c-index-api-fn-scan.m:86:10: VarDecl=c:86:12 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:12: VarDecl=c:86:12 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:13: VarDecl=c:86:12 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:14: VarDecl=c:86:12 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:15: VarDecl=c:86:12 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:16: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:17: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:18: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:19: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:20: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:21: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:22: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:23: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:24: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: c-index-api-fn-scan.m:86:25: ObjCSelectorRef=fooC:25:1 [Context:c] -// CHECK: <invalid loc>:87:2: TypedefDecl=id:0:0 [Context:id] -// CHECK: <invalid loc>:87:3: TypedefDecl=id:0:0 [Context:id] -// CHECK: c-index-api-fn-scan.m:87:5: VarDecl=d:87:13 [Context:d] -// CHECK: c-index-api-fn-scan.m:87:6: ObjCProtocolRef=Proto:40:1 [Context:Proto] -// CHECK: c-index-api-fn-scan.m:87:7: ObjCProtocolRef=Proto:40:1 [Context:Proto] -// CHECK: c-index-api-fn-scan.m:87:8: ObjCProtocolRef=Proto:40:1 [Context:Proto] -// CHECK: c-index-api-fn-scan.m:87:9: ObjCProtocolRef=Proto:40:1 [Context:Proto] -// CHECK: c-index-api-fn-scan.m:87:10: ObjCProtocolRef=Proto:40:1 [Context:Proto] -// CHECK: c-index-api-fn-scan.m:87:11: VarDecl=d:87:13 [Context:d] -// CHECK: c-index-api-fn-scan.m:87:13: VarDecl=d:87:13 [Context:d] -// CHECK: c-index-api-fn-scan.m:88:2: VarRef=d:87:13 [Context:main] -// CHECK: c-index-api-fn-scan.m:88:6: VarRef=c:86:12 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:2: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:3: VarRef=d:87:13 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:4: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:5: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:6: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:7: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:8: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:9: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:10: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:11: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:89:12: ObjCSelectorRef=pMethod:41:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:2: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:3: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:4: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:5: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:6: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:7: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:8: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:9: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:10: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:11: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:12: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:13: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:14: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:15: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:16: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:17: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:18: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:19: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:20: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:21: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:22: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:23: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:24: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:25: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:26: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:27: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:28: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:29: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:30: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:31: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:32: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:33: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:34: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:35: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:36: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:37: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:38: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:39: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:40: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:41: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:42: ObjCSelectorRef=floatMethod:37:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:90:43: ObjCSelectorRef=catMethodWithFloat::36:1 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:3: FunctionRef=main:83:5 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:4: FunctionRef=main:83:5 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:5: FunctionRef=main:83:5 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:6: FunctionRef=main:83:5 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:8: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:9: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:10: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:11: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:12: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:13: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:14: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:15: EnumConstantRef=someEnum:58:3 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:33: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:34: VarRef=bee:84:8 [Context:main] -// CHECK: c-index-api-fn-scan.m:91:35: VarRef=bee:84:8 [Context:main] +// CHECK: c-index-api-fn-scan.m:84:2: ObjCClassRef=Baz:48:1 +// CHECK: c-index-api-fn-scan.m:84:3: ObjCClassRef=Baz:48:1 +// CHECK: c-index-api-fn-scan.m:84:4: ObjCClassRef=Baz:48:1 +// CHECK: c-index-api-fn-scan.m:84:6: VarDecl=bee:84:8 +// CHECK: c-index-api-fn-scan.m:84:8: VarDecl=bee:84:8 +// CHECK: c-index-api-fn-scan.m:84:9: VarDecl=bee:84:8 +// CHECK: c-index-api-fn-scan.m:84:10: VarDecl=bee:84:8 +// CHECK: <invalid loc>:85:2: TypedefDecl=id:0:0 +// CHECK: <invalid loc>:85:3: TypedefDecl=id:0:0 +// CHECK: c-index-api-fn-scan.m:85:5: VarDecl=a:85:5 +// CHECK: c-index-api-fn-scan.m:85:6: VarDecl=a:85:5 +// CHECK: c-index-api-fn-scan.m:85:7: VarDecl=a:85:5 +// CHECK: c-index-api-fn-scan.m:85:8: VarDecl=a:85:5 +// CHECK: c-index-api-fn-scan.m:85:9: ObjCSelectorRef=foo:24:1 +// CHECK: c-index-api-fn-scan.m:85:10: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:85:11: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:85:12: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:85:13: ObjCSelectorRef=foo:24:1 +// CHECK: c-index-api-fn-scan.m:85:14: ObjCSelectorRef=foo:24:1 +// CHECK: c-index-api-fn-scan.m:85:15: ObjCSelectorRef=foo:24:1 +// CHECK: c-index-api-fn-scan.m:85:16: ObjCSelectorRef=foo:24:1 +// CHECK: c-index-api-fn-scan.m:85:17: ObjCSelectorRef=foo:24:1 +// CHECK: <invalid loc>:86:2: TypedefDecl=id:0:0 +// CHECK: <invalid loc>:86:3: TypedefDecl=id:0:0 +// CHECK: c-index-api-fn-scan.m:86:5: VarDecl=c:86:12 +// CHECK: c-index-api-fn-scan.m:86:6: ObjCProtocolRef=SubP:44:1 +// CHECK: c-index-api-fn-scan.m:86:7: ObjCProtocolRef=SubP:44:1 +// CHECK: c-index-api-fn-scan.m:86:8: ObjCProtocolRef=SubP:44:1 +// CHECK: c-index-api-fn-scan.m:86:9: ObjCProtocolRef=SubP:44:1 +// CHECK: c-index-api-fn-scan.m:86:10: VarDecl=c:86:12 +// CHECK: c-index-api-fn-scan.m:86:12: VarDecl=c:86:12 +// CHECK: c-index-api-fn-scan.m:86:13: VarDecl=c:86:12 +// CHECK: c-index-api-fn-scan.m:86:14: VarDecl=c:86:12 +// CHECK: c-index-api-fn-scan.m:86:15: VarDecl=c:86:12 +// CHECK: c-index-api-fn-scan.m:86:16: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:17: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:18: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:19: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:20: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:21: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:22: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:23: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:24: ObjCSelectorRef=fooC:25:1 +// CHECK: c-index-api-fn-scan.m:86:25: ObjCSelectorRef=fooC:25:1 +// CHECK: <invalid loc>:87:2: TypedefDecl=id:0:0 +// CHECK: <invalid loc>:87:3: TypedefDecl=id:0:0 +// CHECK: c-index-api-fn-scan.m:87:5: VarDecl=d:87:13 +// CHECK: c-index-api-fn-scan.m:87:6: ObjCProtocolRef=Proto:40:1 +// CHECK: c-index-api-fn-scan.m:87:7: ObjCProtocolRef=Proto:40:1 +// CHECK: c-index-api-fn-scan.m:87:8: ObjCProtocolRef=Proto:40:1 +// CHECK: c-index-api-fn-scan.m:87:9: ObjCProtocolRef=Proto:40:1 +// CHECK: c-index-api-fn-scan.m:87:10: ObjCProtocolRef=Proto:40:1 +// CHECK: c-index-api-fn-scan.m:87:11: VarDecl=d:87:13 +// CHECK: c-index-api-fn-scan.m:87:13: VarDecl=d:87:13 +// CHECK: c-index-api-fn-scan.m:88:2: VarRef=d:87:13 +// CHECK: c-index-api-fn-scan.m:88:6: VarRef=c:86:12 +// CHECK: c-index-api-fn-scan.m:89:2: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:3: VarRef=d:87:13 +// CHECK: c-index-api-fn-scan.m:89:4: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:5: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:6: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:7: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:8: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:9: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:10: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:11: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:89:12: ObjCSelectorRef=pMethod:41:1 +// CHECK: c-index-api-fn-scan.m:90:2: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:3: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:90:4: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:90:5: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:90:6: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:7: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:8: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:9: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:10: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:11: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:12: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:13: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:14: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:15: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:16: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:17: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:18: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:19: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:20: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:21: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:22: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:23: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:24: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:25: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:90:26: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:27: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:90:28: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:90:29: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:90:30: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:31: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:32: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:33: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:34: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:35: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:36: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:37: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:38: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:39: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:40: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:41: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:42: ObjCSelectorRef=floatMethod:37:1 +// CHECK: c-index-api-fn-scan.m:90:43: ObjCSelectorRef=catMethodWithFloat::36:1 +// CHECK: c-index-api-fn-scan.m:91:3: FunctionRef=main:83:5 +// CHECK: c-index-api-fn-scan.m:91:4: FunctionRef=main:83:5 +// CHECK: c-index-api-fn-scan.m:91:5: FunctionRef=main:83:5 +// CHECK: c-index-api-fn-scan.m:91:6: FunctionRef=main:83:5 +// CHECK: c-index-api-fn-scan.m:91:8: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:9: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:10: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:11: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:12: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:13: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:14: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:15: EnumConstantRef=someEnum:58:3 +// CHECK: c-index-api-fn-scan.m:91:33: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:91:34: VarRef=bee:84:8 +// CHECK: c-index-api-fn-scan.m:91:35: VarRef=bee:84:8 diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 62485430b0..9d126c8a97 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -53,33 +53,33 @@ int main (int argc, const char * argv[]) { main(someEnum, (const char **)bee); } -// CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:1 [Context=c-index-api-loadTU-test.m] [Extent=4:1:11:4] -// CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=foo:8:1 [Context=Foo] [Extent=8:1:8:6] -// CHECK: c-index-api-loadTU-test.m:9:1: ObjCClassMethodDecl=fooC:9:1 [Context=Foo] [Extent=9:1:9:7] -// CHECK: c-index-api-loadTU-test.m:13:12: ObjCInterfaceDecl=Bar:13:1 [Context=c-index-api-loadTU-test.m] [Extent=13:1:17:4] -// CHECK: c-index-api-loadTU-test.m:13:18: ObjCSuperClassRef=Foo:4:1 [Context=Bar] [Extent=4:1:11:4] -// CHECK: c-index-api-loadTU-test.m:19:12: ObjCCategoryDecl=FooCat:19:12 [Context=c-index-api-loadTU-test.m] [Extent=19:1:22:4] -// CHECK: c-index-api-loadTU-test.m:19:12: ObjCClassRef=Foo:4:1 [Context=FooCat] [Extent=4:1:11:4] -// CHECK: c-index-api-loadTU-test.m:20:1: ObjCInstanceMethodDecl=catMethodWithFloat::20:1 [Context=FooCat] [Extent=20:1:20:40] -// CHECK: c-index-api-loadTU-test.m:21:1: ObjCInstanceMethodDecl=floatMethod:21:1 [Context=FooCat] [Extent=21:1:21:22] -// CHECK: c-index-api-loadTU-test.m:24:1: ObjCProtocolDecl=Proto:24:1 [Context=c-index-api-loadTU-test.m] [Extent=24:1:26:4] -// CHECK: c-index-api-loadTU-test.m:25:1: ObjCInstanceMethodDecl=pMethod:25:1 [Context=Proto] [Extent=25:1:25:10] -// CHECK: c-index-api-loadTU-test.m:28:1: ObjCProtocolDecl=SubP:28:1 [Context=c-index-api-loadTU-test.m] [Extent=28:1:30:4] -// CHECK: c-index-api-loadTU-test.m:28:17: ObjCProtocolRef=Proto:24:1 [Context=SubP] [Extent=24:1:26:4] -// CHECK: c-index-api-loadTU-test.m:29:1: ObjCInstanceMethodDecl=spMethod:29:1 [Context=SubP] [Extent=29:1:29:11] -// CHECK: c-index-api-loadTU-test.m:32:12: ObjCInterfaceDecl=Baz:32:1 [Context=c-index-api-loadTU-test.m] [Extent=32:1:39:4] -// CHECK: c-index-api-loadTU-test.m:32:18: ObjCSuperClassRef=Bar:13:1 [Context=Baz] [Extent=13:1:17:4] -// CHECK: c-index-api-loadTU-test.m:32:23: ObjCProtocolRef=SubP:28:1 [Context=Baz] [Extent=28:1:30:4] -// CHECK: c-index-api-loadTU-test.m:34:9: ObjCIvarDecl=_anIVar:34:9 [Context=Baz] [Extent=34:9:34:15] -// CHECK: c-index-api-loadTU-test.m:37:1: ObjCInstanceMethodDecl=bazMethod:37:1 [Context=Baz] [Extent=37:1:37:20] -// CHECK: c-index-api-loadTU-test.m:41:1: EnumDecl=:41:1 [Context=c-index-api-loadTU-test.m] [Extent=41:1:43:1] -// CHECK: c-index-api-loadTU-test.m:42:3: EnumConstantDecl=someEnum:42:3 [Context=] [Extent=42:3:42:10] -// CHECK: c-index-api-loadTU-test.m:45:5: FunctionDefn=main:45:5 [Context=c-index-api-loadTU-test.m] [Extent=45:5:54:1] -// CHECK: c-index-api-loadTU-test.m:45:15: ParmDecl=argc:45:15 [Context=main] [Extent=45:15:45:18] -// CHECK: c-index-api-loadTU-test.m:45:34: ParmDecl=argv:45:34 [Context=main] [Extent=45:34:45:37] -// CHECK: c-index-api-loadTU-test.m:46:8: VarDecl=bee:46:8 [Context=main] [Extent=46:8:46:10] -// CHECK: c-index-api-loadTU-test.m:47:5: VarDecl=a:47:5 [Context=main] [Extent=47:5:47:17] -// CHECK: c-index-api-loadTU-test.m:48:12: VarDecl=c:48:12 [Context=main] [Extent=48:12:48:25] -// CHECK: c-index-api-loadTU-test.m:49:13: VarDecl=d:49:13 [Context=main] [Extent=49:13:49:13] +// CHECK: c-index-api-loadTU-test.m:4:12: ObjCInterfaceDecl=Foo:4:1 [Extent=4:1:11:4] +// CHECK: c-index-api-loadTU-test.m:8:1: ObjCInstanceMethodDecl=foo:8:1 [Extent=8:1:8:6] +// CHECK: c-index-api-loadTU-test.m:9:1: ObjCClassMethodDecl=fooC:9:1 [Extent=9:1:9:7] +// CHECK: c-index-api-loadTU-test.m:13:12: ObjCInterfaceDecl=Bar:13:1 [Extent=13:1:17:4] +// CHECK: c-index-api-loadTU-test.m:13:18: ObjCSuperClassRef=Foo:4:1 [Extent=4:1:11:4] +// CHECK: c-index-api-loadTU-test.m:19:12: ObjCCategoryDecl=FooCat:19:12 [Extent=19:1:22:4] +// CHECK: c-index-api-loadTU-test.m:19:12: ObjCClassRef=Foo:4:1 [Extent=4:1:11:4] +// CHECK: c-index-api-loadTU-test.m:20:1: ObjCInstanceMethodDecl=catMethodWithFloat::20:1 [Extent=20:1:20:40] +// CHECK: c-index-api-loadTU-test.m:21:1: ObjCInstanceMethodDecl=floatMethod:21:1 [Extent=21:1:21:22] +// CHECK: c-index-api-loadTU-test.m:24:1: ObjCProtocolDecl=Proto:24:1 [Extent=24:1:26:4] +// CHECK: c-index-api-loadTU-test.m:25:1: ObjCInstanceMethodDecl=pMethod:25:1 [Extent=25:1:25:10] +// CHECK: c-index-api-loadTU-test.m:28:1: ObjCProtocolDecl=SubP:28:1 [Extent=28:1:30:4] +// CHECK: c-index-api-loadTU-test.m:28:17: ObjCProtocolRef=Proto:24:1 [Extent=24:1:26:4] +// CHECK: c-index-api-loadTU-test.m:29:1: ObjCInstanceMethodDecl=spMethod:29:1 [Extent=29:1:29:11] +// CHECK: c-index-api-loadTU-test.m:32:12: ObjCInterfaceDecl=Baz:32:1 [Extent=32:1:39:4] +// CHECK: c-index-api-loadTU-test.m:32:18: ObjCSuperClassRef=Bar:13:1 [Extent=13:1:17:4] +// CHECK: c-index-api-loadTU-test.m:32:23: ObjCProtocolRef=SubP:28:1 [Extent=28:1:30:4] +// CHECK: c-index-api-loadTU-test.m:34:9: ObjCIvarDecl=_anIVar:34:9 [Extent=34:9:34:15] +// CHECK: c-index-api-loadTU-test.m:37:1: ObjCInstanceMethodDecl=bazMethod:37:1 [Extent=37:1:37:20] +// CHECK: c-index-api-loadTU-test.m:41:1: EnumDecl=:41:1 [Extent=41:1:43:1] +// CHECK: c-index-api-loadTU-test.m:42:3: EnumConstantDecl=someEnum:42:3 [Extent=42:3:42:10] +// CHECK: c-index-api-loadTU-test.m:45:5: FunctionDefn=main:45:5 [Extent=45:5:54:1] +// CHECK: c-index-api-loadTU-test.m:45:15: ParmDecl=argc:45:15 [Extent=45:15:45:18] +// CHECK: c-index-api-loadTU-test.m:45:34: ParmDecl=argv:45:34 [Extent=45:34:45:37] +// CHECK: c-index-api-loadTU-test.m:46:8: VarDecl=bee:46:8 [Extent=46:8:46:10] +// CHECK: c-index-api-loadTU-test.m:47:5: VarDecl=a:47:5 [Extent=47:5:47:17] +// CHECK: c-index-api-loadTU-test.m:48:12: VarDecl=c:48:12 [Extent=48:12:48:25] +// CHECK: c-index-api-loadTU-test.m:49:13: VarDecl=d:49:13 [Extent=49:13:49:13] diff --git a/test/Index/cindex-from-source.m b/test/Index/cindex-from-source.m index e775bb71e1..9f9dd21902 100644 --- a/test/Index/cindex-from-source.m +++ b/test/Index/cindex-from-source.m @@ -2,8 +2,8 @@ // RUN: %clang -x objective-c-header %t.pfx.h -o %t.pfx.h.gch // RUN: c-index-test -test-load-source local %s -include %t.pfx.h > %t // RUN: FileCheck %s < %t -// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: StructDecl=s0:{{.*}}:{{.*}} [Context=cindex-from-source.m] -// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: VarDecl=g0:{{.*}}:{{.*}} [Context=cindex-from-source.m] +// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: StructDecl=s0:{{.*}}:{{.*}} +// CHECK: cindex-from-source.m:{{.*}}:{{.*}}: VarDecl=g0:{{.*}}:{{.*}} struct s0 {}; t0 g0; diff --git a/tools/CIndex/CIndex.exports b/tools/CIndex/CIndex.exports index a695ba2b08..d5f8298997 100644 --- a/tools/CIndex/CIndex.exports +++ b/tools/CIndex/CIndex.exports @@ -21,14 +21,14 @@ _clang_getCursorLine _clang_getCursorSource _clang_getCursorSourceFile _clang_getCursorSpelling +_clang_getCursorUSR _clang_getDeclColumn _clang_getDeclExtent -_clang_getDeclLine _clang_getDeclExtent +_clang_getDeclLine _clang_getDeclSource _clang_getDeclSourceFile _clang_getDeclSpelling -_clang_getDeclUSR _clang_getDeclaration _clang_getDefinitionSpellingAndExtent _clang_getEntityFromDecl diff --git a/tools/CIndex/CIndexUSRs.cpp b/tools/CIndex/CIndexUSRs.cpp index b52b9da921..c8933fa000 100644 --- a/tools/CIndex/CIndexUSRs.cpp +++ b/tools/CIndex/CIndexUSRs.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "CIndexer.h" +#include "CXCursor.h" #include "clang/AST/DeclVisitor.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" @@ -184,6 +185,23 @@ void USRGenerator::VisitTypedefDecl(TypedefDecl *D) { Out << "typedef@" << D->getName(); } +// FIXME: This is a skeleton implementation. It will be overhauled. +static CXString ConstructUSR(Decl *D) { + llvm::SmallString<1024> StrBuf; + { + llvm::raw_svector_ostream Out(StrBuf); + USRGenerator UG(Out); + UG.Visit(static_cast<Decl*>(D)); + } + + if (StrBuf.empty()) + return CIndexer::createCXString(NULL); + + // Return a copy of the string that must be disposed by the caller. + return CIndexer::createCXString(StrBuf.c_str(), true); +} + + extern "C" { /// clang_getDeclaration() maps from a CXEntity to the matching CXDecl (if any) @@ -198,22 +216,13 @@ CXEntity clang_getEntityFromDecl(CXIndex CIdx, CXDecl CE) { return MakeEntity(CIdx, Entity::get(D, GetProgram(CIdx))); return NullCXEntity(); } - -// FIXME: This is a skeleton implementation. It will be overhauled. -CXString clang_getDeclUSR(CXDecl D) { - assert(D && "Null CXDecl passed to clang_getDeclUSR()"); - llvm::SmallString<1024> StrBuf; - { - llvm::raw_svector_ostream Out(StrBuf); - USRGenerator UG(Out); - UG.Visit(static_cast<Decl*>(D)); - } - - if (StrBuf.empty()) - return CIndexer::createCXString(NULL); - // Return a copy of the string that must be disposed by the caller. - return CIndexer::createCXString(StrBuf.c_str(), true); -} +CXString clang_getCursorUSR(CXCursor C) { + if (Decl *D = cxcursor::getCursorDecl(C)) + return ConstructUSR(D); + + + return CIndexer::createCXString(NULL); +} } // end extern "C" diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c index afceafab20..db95644c4c 100644 --- a/tools/c-index-test/c-index-test.c +++ b/tools/c-index-test/c-index-test.c @@ -84,17 +84,11 @@ static void PrintDeclExtent(CXDecl Dcl) { static void DeclVisitor(CXDecl Dcl, CXCursor Cursor, CXClientData Filter) { if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { - CXString string; printf("// %s: %s:%d:%d: ", FileCheckPrefix, GetCursorSource(Cursor), clang_getCursorLine(Cursor), clang_getCursorColumn(Cursor)); - PrintCursor(Cursor); - - string = clang_getDeclSpelling(Dcl); - printf(" [Context=%s]", clang_getCString(string)); - clang_disposeString(string); - + PrintCursor(Cursor); PrintDeclExtent(clang_getCursorDecl(Cursor)); printf("\n"); @@ -105,15 +99,10 @@ static void TranslationUnitVisitor(CXTranslationUnit Unit, CXCursor Cursor, CXClientData Filter) { if (!Filter || (Cursor.kind == *(enum CXCursorKind *)Filter)) { CXDecl D; - CXString string; printf("// %s: %s:%d:%d: ", FileCheckPrefix, GetCursorSource(Cursor), clang_getCursorLine(Cursor), clang_getCursorColumn(Cursor)); PrintCursor(Cursor); - string = clang_getTranslationUnitSpelling(Unit); - printf(" [Context=%s]", - basename(clang_getCString(string))); - clang_disposeString(string); D = clang_getCursorDecl(Cursor); if (!D) { @@ -156,13 +145,10 @@ static void FunctionScanVisitor(CXTranslationUnit Unit, CXCursor Cursor, if (Ref.kind == CXCursor_NoDeclFound) { /* Nothing found here; that's fine. */ } else if (Ref.kind != CXCursor_FunctionDecl) { - CXString string; printf("// %s: %s:%d:%d: ", FileCheckPrefix, GetCursorSource(Ref), curLine, curColumn); PrintCursor(Ref); - string = clang_getDeclSpelling(Ref.data[0]); - printf(" [Context:%s]\n", clang_getCString(string)); - clang_disposeString(string); + printf("\n"); } startBuf++; } @@ -174,13 +160,13 @@ static void FunctionScanVisitor(CXTranslationUnit Unit, CXCursor Cursor, static void USRDeclVisitor(CXDecl D, CXCursor C, CXClientData Filter) { if (!Filter || (C.kind == *(enum CXCursorKind *)Filter)) { - CXString USR = clang_getDeclUSR(C.data[0]); + CXString USR = clang_getCursorUSR(C); if (!USR.Spelling) { clang_disposeString(USR); return; } printf("// %s: %s %s", FileCheckPrefix, GetCursorSource(C), USR.Spelling); - PrintDeclExtent(C.data[0]); + PrintDeclExtent(clang_getCursorDecl(C)); printf("\n"); clang_disposeString(USR); } |