From 4279d60f88e3c483a7f453efb1b934e8dfdde032 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 3 Mar 2014 19:40:52 +0000 Subject: [PATCH] [libclang] Have clang_getCursorSpelling() return the string for a CXCursor_ObjCStringLiteral or CXCursor_StringLiteral cursor. rdar://16206459 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202745 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Index/local-symbols.m | 7 + test/Index/recursive-cxx-member-calls.cpp | 162 +++++++++++----------- tools/libclang/CIndex.cpp | 16 +++ 3 files changed, 104 insertions(+), 81 deletions(-) diff --git a/test/Index/local-symbols.m b/test/Index/local-symbols.m index b4eb262583..c7b903a9e4 100644 --- a/test/Index/local-symbols.m +++ b/test/Index/local-symbols.m @@ -26,6 +26,12 @@ @interface R8380046 () @end +@class NSString; + +void test() { + NSString *s = @"objc str"; +} + // 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:3 - 7:7] // CHECK: local-symbols.m:7:3: TypeRef=id:0:0 Extent=[7:3 - 7:5] @@ -42,3 +48,4 @@ // CHECK: local-symbols.m:26:12: ObjCClassRef=R8380046:23:12 Extent=[26:12 - 26:20] // CHECK: local-symbols.m:26:25: ObjCProtocolRef=Prot8380046:20:11 Extent=[26:25 - 26:36] +// CHECK: local-symbols.m:32:17: ObjCStringLiteral="objc str" Extent=[32:17 - 32:28] diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp index 04a3c5cf92..ab30d43905 100644 --- a/test/Index/recursive-cxx-member-calls.cpp +++ b/test/Index/recursive-cxx-member-calls.cpp @@ -1888,7 +1888,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 102:27: UnexposedExpr=StringRef:48:3 Extent=[102:27 - 102:31] // CHECK: 102:27: CallExpr=StringRef:48:3 Extent=[102:27 - 102:31] // CHECK: 102:27: UnexposedExpr= Extent=[102:27 - 102:31] -// CHECK: 102:27: StringLiteral= Extent=[102:27 - 102:31] +// CHECK: 102:27: StringLiteral="__" Extent=[102:27 - 102:31] // CHECK: 102:36: CallExpr=endswith:56:8 Extent=[102:36 - 102:59] // CHECK: 102:45: MemberRefExpr=endswith:56:8 SingleRefName=[102:45 - 102:53] RefName=[102:45 - 102:53] Extent=[102:36 - 102:53] // CHECK: 102:36: UnexposedExpr=AttrName:101:19 Extent=[102:36 - 102:44] @@ -1898,7 +1898,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 102:54: UnexposedExpr=StringRef:48:3 Extent=[102:54 - 102:58] // CHECK: 102:54: CallExpr=StringRef:48:3 Extent=[102:54 - 102:58] // CHECK: 102:54: UnexposedExpr= Extent=[102:54 - 102:58] -// CHECK: 102:54: StringLiteral= Extent=[102:54 - 102:58] +// CHECK: 102:54: StringLiteral="__" Extent=[102:54 - 102:58] // CHECK: 103:5: CallExpr=operator=:38:7 Extent=[103:5 - 103:55] // CHECK: 103:5: DeclRefExpr=AttrName:101:19 Extent=[103:5 - 103:13] // CHECK: 103:14: UnexposedExpr=operator=:38:7 @@ -2085,158 +2085,158 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 105:54: CallExpr=StringRef:38:7 Extent=[105:54 - 105:62] // CHECK: 105:54: UnexposedExpr=AttrName:101:19 Extent=[105:54 - 105:62] // CHECK: 105:54: DeclRefExpr=AttrName:101:19 Extent=[105:54 - 105:62] -// CHECK: 106:11: StringLiteral= Extent=[106:11 - 106:17] +// CHECK: 106:11: StringLiteral="weak" Extent=[106:11 - 106:17] // CHECK: 106:19: DeclRefExpr=AT_weak:29:45 Extent=[106:19 - 106:26] -// CHECK: 107:11: StringLiteral= Extent=[107:11 - 107:20] +// CHECK: 107:11: StringLiteral="weakref" Extent=[107:11 - 107:20] // CHECK: 107:22: DeclRefExpr=AT_weakref:29:54 Extent=[107:22 - 107:32] -// CHECK: 108:11: StringLiteral= Extent=[108:11 - 108:17] +// CHECK: 108:11: StringLiteral="pure" Extent=[108:11 - 108:17] // CHECK: 108:19: DeclRefExpr=AT_pure:26:49 Extent=[108:19 - 108:26] -// CHECK: 109:11: StringLiteral= Extent=[109:11 - 109:17] +// CHECK: 109:11: StringLiteral="mode" Extent=[109:11 - 109:17] // CHECK: 109:19: DeclRefExpr=AT_mode:20:44 Extent=[109:19 - 109:26] -// CHECK: 110:11: StringLiteral= Extent=[110:11 - 110:17] +// CHECK: 110:11: StringLiteral="used" Extent=[110:11 - 110:17] // CHECK: 110:19: DeclRefExpr=AT_used:28:34 Extent=[110:19 - 110:26] -// CHECK: 111:11: StringLiteral= Extent=[111:11 - 111:18] +// CHECK: 111:11: StringLiteral="alias" Extent=[111:11 - 111:18] // CHECK: 111:20: DeclRefExpr=AT_alias:15:25 Extent=[111:20 - 111:28] -// CHECK: 112:11: StringLiteral= Extent=[112:11 - 112:18] +// CHECK: 112:11: StringLiteral="align" Extent=[112:11 - 112:18] // CHECK: 112:20: DeclRefExpr=AT_aligned:15:35 Extent=[112:20 - 112:30] -// CHECK: 113:11: StringLiteral= Extent=[113:11 - 113:18] +// CHECK: 113:11: StringLiteral="final" Extent=[113:11 - 113:18] // CHECK: 113:20: DeclRefExpr=AT_final:19:40 Extent=[113:20 - 113:28] -// CHECK: 114:11: StringLiteral= Extent=[114:11 - 114:18] +// CHECK: 114:11: StringLiteral="cdecl" Extent=[114:11 - 114:18] // CHECK: 114:20: DeclRefExpr=AT_cdecl:17:30 Extent=[114:20 - 114:28] -// CHECK: 115:11: StringLiteral= Extent=[115:11 - 115:18] +// CHECK: 115:11: StringLiteral="const" Extent=[115:11 - 115:18] // CHECK: 115:20: DeclRefExpr=AT_const:17:52 Extent=[115:20 - 115:28] -// CHECK: 116:11: StringLiteral= Extent=[116:11 - 116:20] +// CHECK: 116:11: StringLiteral="__const" Extent=[116:11 - 116:20] // CHECK: 116:22: DeclRefExpr=AT_const:17:52 Extent=[116:22 - 116:30] -// CHECK: 117:11: StringLiteral= Extent=[117:11 - 117:19] +// CHECK: 117:11: StringLiteral="blocks" Extent=[117:11 - 117:19] // CHECK: 117:21: DeclRefExpr=AT_blocks:16:57 Extent=[117:21 - 117:30] -// CHECK: 118:11: StringLiteral= Extent=[118:11 - 118:19] +// CHECK: 118:11: StringLiteral="format" Extent=[118:11 - 118:19] // CHECK: 118:21: DeclRefExpr=AT_format:19:50 Extent=[118:21 - 118:30] -// CHECK: 119:11: StringLiteral= Extent=[119:11 - 119:19] +// CHECK: 119:11: StringLiteral="hiding" Extent=[119:11 - 119:19] // CHECK: 119:21: DeclRefExpr=AT_hiding:20:22 Extent=[119:21 - 119:30] -// CHECK: 120:11: StringLiteral= Extent=[120:11 - 120:19] +// CHECK: 120:11: StringLiteral="malloc" Extent=[120:11 - 120:19] // CHECK: 120:21: DeclRefExpr=AT_malloc:20:33 Extent=[120:21 - 120:30] -// CHECK: 121:11: StringLiteral= Extent=[121:11 - 121:19] +// CHECK: 121:11: StringLiteral="packed" Extent=[121:11 - 121:19] // CHECK: 121:21: DeclRefExpr=AT_packed:26:27 Extent=[121:21 - 121:30] -// CHECK: 122:11: StringLiteral= Extent=[122:11 - 122:19] +// CHECK: 122:11: StringLiteral="unused" Extent=[122:11 - 122:19] // CHECK: 122:21: DeclRefExpr=AT_unused:28:23 Extent=[122:21 - 122:30] -// CHECK: 123:11: StringLiteral= Extent=[123:11 - 123:20] +// CHECK: 123:11: StringLiteral="aligned" Extent=[123:11 - 123:20] // CHECK: 123:22: DeclRefExpr=AT_aligned:15:35 Extent=[123:22 - 123:32] -// CHECK: 124:11: StringLiteral= Extent=[124:11 - 124:20] +// CHECK: 124:11: StringLiteral="cleanup" Extent=[124:11 - 124:20] // CHECK: 124:22: DeclRefExpr=AT_cleanup:17:40 Extent=[124:22 - 124:32] -// CHECK: 125:11: StringLiteral= Extent=[125:11 - 125:18] +// CHECK: 125:11: StringLiteral="naked" Extent=[125:11 - 125:18] // CHECK: 125:20: DeclRefExpr=AT_naked:20:53 Extent=[125:20 - 125:28] -// CHECK: 126:11: StringLiteral= Extent=[126:11 - 126:20] +// CHECK: 126:11: StringLiteral="nodebug" Extent=[126:11 - 126:20] // CHECK: 126:22: DeclRefExpr=AT_nodebug:20:63 Extent=[126:22 - 126:32] -// CHECK: 127:11: StringLiteral= Extent=[127:11 - 127:20] +// CHECK: 127:11: StringLiteral="nonnull" Extent=[127:11 - 127:20] // CHECK: 127:22: DeclRefExpr=AT_nonnull:21:47 Extent=[127:22 - 127:32] -// CHECK: 128:11: StringLiteral= Extent=[128:11 - 128:20] +// CHECK: 128:11: StringLiteral="nothrow" Extent=[128:11 - 128:20] // CHECK: 128:22: DeclRefExpr=AT_nothrow:22:7 Extent=[128:22 - 128:32] -// CHECK: 129:11: StringLiteral= Extent=[129:11 - 129:20] +// CHECK: 129:11: StringLiteral="objc_gc" Extent=[129:11 - 129:20] // CHECK: 129:22: DeclRefExpr=AT_objc_gc:24:59 Extent=[129:22 - 129:32] -// CHECK: 130:11: StringLiteral= Extent=[130:11 - 130:20] +// CHECK: 130:11: StringLiteral="regparm" Extent=[130:11 - 130:20] // CHECK: 130:22: DeclRefExpr=AT_regparm:26:58 Extent=[130:22 - 130:32] -// CHECK: 131:11: StringLiteral= Extent=[131:11 - 131:20] +// CHECK: 131:11: StringLiteral="section" Extent=[131:11 - 131:20] // CHECK: 131:22: DeclRefExpr=AT_section:27:7 Extent=[131:22 - 131:32] -// CHECK: 132:11: StringLiteral= Extent=[132:11 - 132:20] +// CHECK: 132:11: StringLiteral="stdcall" Extent=[132:11 - 132:20] // CHECK: 132:22: DeclRefExpr=AT_stdcall:27:32 Extent=[132:22 - 132:32] -// CHECK: 133:11: StringLiteral= Extent=[133:11 - 133:21] +// CHECK: 133:11: StringLiteral="annotate" Extent=[133:11 - 133:21] // CHECK: 133:23: DeclRefExpr=AT_annotate:16:29 Extent=[133:23 - 133:34] -// CHECK: 134:11: StringLiteral= Extent=[134:11 - 134:21] +// CHECK: 134:11: StringLiteral="fastcall" Extent=[134:11 - 134:21] // CHECK: 134:23: DeclRefExpr=AT_fastcall:19:27 Extent=[134:23 - 134:34] -// CHECK: 135:11: StringLiteral= Extent=[135:11 - 135:21] +// CHECK: 135:11: StringLiteral="ibaction" Extent=[135:11 - 135:21] // CHECK: 135:23: DeclRefExpr=AT_IBAction:14:7 Extent=[135:23 - 135:34] -// CHECK: 136:11: StringLiteral= Extent=[136:11 - 136:21] +// CHECK: 136:11: StringLiteral="iboutlet" Extent=[136:11 - 136:21] // CHECK: 136:23: DeclRefExpr=AT_IBOutlet:14:20 Extent=[136:23 - 136:34] -// CHECK: 137:11: StringLiteral= Extent=[137:11 - 137:31] +// CHECK: 137:11: StringLiteral="iboutletcollection" Extent=[137:11 - 137:31] // CHECK: 137:33: DeclRefExpr=AT_IBOutletCollection:14:33 Extent=[137:33 - 137:54] -// CHECK: 138:11: StringLiteral= Extent=[138:11 - 138:21] +// CHECK: 138:11: StringLiteral="noreturn" Extent=[138:11 - 138:21] // CHECK: 138:23: DeclRefExpr=AT_noreturn:21:59 Extent=[138:23 - 138:34] -// CHECK: 139:11: StringLiteral= Extent=[139:11 - 139:21] +// CHECK: 139:11: StringLiteral="noinline" Extent=[139:11 - 139:21] // CHECK: 139:23: DeclRefExpr=AT_noinline:21:7 Extent=[139:23 - 139:34] -// CHECK: 140:11: StringLiteral= Extent=[140:11 - 140:21] +// CHECK: 140:11: StringLiteral="override" Extent=[140:11 - 140:21] // CHECK: 140:23: DeclRefExpr=AT_override:22:51 Extent=[140:23 - 140:34] -// CHECK: 141:11: StringLiteral= Extent=[141:11 - 141:21] +// CHECK: 141:11: StringLiteral="sentinel" Extent=[141:11 - 141:21] // CHECK: 141:23: DeclRefExpr=AT_sentinel:27:19 Extent=[141:23 - 141:34] -// CHECK: 142:11: StringLiteral= Extent=[142:11 - 142:21] +// CHECK: 142:11: StringLiteral="NSObject" Extent=[142:11 - 142:21] // CHECK: 142:23: DeclRefExpr=AT_nsobject:22:19 Extent=[142:23 - 142:34] -// CHECK: 143:11: StringLiteral= Extent=[143:11 - 143:22] +// CHECK: 143:11: StringLiteral="dllimport" Extent=[143:11 - 143:22] // CHECK: 143:24: DeclRefExpr=AT_dllimport:18:51 Extent=[143:24 - 143:36] -// CHECK: 144:11: StringLiteral= Extent=[144:11 - 144:22] +// CHECK: 144:11: StringLiteral="dllexport" Extent=[144:11 - 144:22] // CHECK: 144:24: DeclRefExpr=AT_dllexport:18:37 Extent=[144:24 - 144:36] -// CHECK: 145:11: StringLiteral= Extent=[145:11 - 145:22] -// CHECK: 146:11: StringLiteral= Extent=[146:11 - 146:23] +// CHECK: 145:11: StringLiteral="may_alias" Extent=[145:11 - 145:22] +// CHECK: 146:11: StringLiteral="base_check" Extent=[146:11 - 146:23] // CHECK: 146:25: DeclRefExpr=AT_base_check:16:42 Extent=[146:25 - 146:38] -// CHECK: 147:11: StringLiteral= Extent=[147:11 - 147:23] +// CHECK: 147:11: StringLiteral="deprecated" Extent=[147:11 - 147:23] // CHECK: 147:25: DeclRefExpr=AT_deprecated:18:7 Extent=[147:25 - 147:38] -// CHECK: 148:11: StringLiteral= Extent=[148:11 - 148:23] +// CHECK: 148:11: StringLiteral="visibility" Extent=[148:11 - 148:23] // CHECK: 148:25: DeclRefExpr=AT_visibility:29:7 Extent=[148:25 - 148:38] -// CHECK: 149:11: StringLiteral= Extent=[149:11 - 149:23] +// CHECK: 149:11: StringLiteral="destructor" Extent=[149:11 - 149:23] // CHECK: 149:25: DeclRefExpr=AT_destructor:18:22 Extent=[149:25 - 149:38] -// CHECK: 150:11: StringLiteral= Extent=[150:11 - 150:23] +// CHECK: 150:11: StringLiteral="format_arg" Extent=[150:11 - 150:23] // CHECK: 150:25: DeclRefExpr=AT_format_arg:19:61 Extent=[150:25 - 150:38] -// CHECK: 151:11: StringLiteral= Extent=[151:11 - 151:23] +// CHECK: 151:11: StringLiteral="gnu_inline" Extent=[151:11 - 151:23] // CHECK: 151:25: DeclRefExpr=AT_gnu_inline:20:7 Extent=[151:25 - 151:38] -// CHECK: 152:11: StringLiteral= Extent=[152:11 - 152:24] +// CHECK: 152:11: StringLiteral="weak_import" Extent=[152:11 - 152:24] // CHECK: 152:26: DeclRefExpr=AT_weak_import:30:7 Extent=[152:26 - 152:40] -// CHECK: 153:11: StringLiteral= Extent=[153:11 - 153:22] +// CHECK: 153:11: StringLiteral="vecreturn" Extent=[153:11 - 153:22] // CHECK: 153:24: DeclRefExpr=AT_vecreturn:28:43 Extent=[153:24 - 153:36] -// CHECK: 154:11: StringLiteral= Extent=[154:11 - 154:24] +// CHECK: 154:11: StringLiteral="vector_size" Extent=[154:11 - 154:24] // CHECK: 154:26: DeclRefExpr=AT_vector_size:28:57 Extent=[154:26 - 154:40] -// CHECK: 155:11: StringLiteral= Extent=[155:11 - 155:24] +// CHECK: 155:11: StringLiteral="constructor" Extent=[155:11 - 155:24] // CHECK: 155:26: DeclRefExpr=AT_constructor:17:62 Extent=[155:26 - 155:40] -// CHECK: 156:11: StringLiteral= Extent=[156:11 - 156:24] +// CHECK: 156:11: StringLiteral="unavailable" Extent=[156:11 - 156:24] // CHECK: 156:26: DeclRefExpr=AT_unavailable:28:7 Extent=[156:26 - 156:40] -// CHECK: 157:11: StringLiteral= Extent=[157:11 - 157:25] +// CHECK: 157:11: StringLiteral="overloadable" Extent=[157:11 - 157:25] // CHECK: 157:27: DeclRefExpr=AT_overloadable:25:7 Extent=[157:27 - 157:42] -// CHECK: 158:11: StringLiteral= Extent=[158:11 - 158:26] +// CHECK: 158:11: StringLiteral="address_space" Extent=[158:11 - 158:26] // CHECK: 158:28: DeclRefExpr=AT_address_space:15:7 Extent=[158:28 - 158:44] -// CHECK: 159:11: StringLiteral= Extent=[159:11 - 159:26] +// CHECK: 159:11: StringLiteral="always_inline" Extent=[159:11 - 159:26] // CHECK: 159:28: DeclRefExpr=AT_always_inline:15:47 Extent=[159:28 - 159:44] -// CHECK: 160:11: StringLiteral= Extent=[160:11 - 160:26] -// CHECK: 161:11: StringLiteral= Extent=[161:11 - 161:26] -// CHECK: 162:11: StringLiteral= Extent=[162:11 - 162:27] +// CHECK: 160:11: StringLiteral="returns_twice" Extent=[160:11 - 160:26] +// CHECK: 161:11: StringLiteral="vec_type_hint" Extent=[161:11 - 161:26] +// CHECK: 162:11: StringLiteral="objc_exception" Extent=[162:11 - 162:27] // CHECK: 162:29: DeclRefExpr=AT_objc_exception:22:32 Extent=[162:29 - 162:46] -// CHECK: 163:11: StringLiteral= Extent=[163:11 - 163:28] +// CHECK: 163:11: StringLiteral="ext_vector_type" Extent=[163:11 - 163:28] // CHECK: 163:30: DeclRefExpr=AT_ext_vector_type:19:7 Extent=[163:30 - 163:48] -// CHECK: 164:11: StringLiteral= Extent=[164:11 - 164:30] +// CHECK: 164:11: StringLiteral="transparent_union" Extent=[164:11 - 164:30] // CHECK: 164:32: DeclRefExpr=AT_transparent_union:27:57 Extent=[164:32 - 164:52] -// CHECK: 165:11: StringLiteral= Extent=[165:11 - 165:30] +// CHECK: 165:11: StringLiteral="analyzer_noreturn" Extent=[165:11 - 165:30] // CHECK: 165:32: DeclRefExpr=AT_analyzer_noreturn:16:7 Extent=[165:32 - 165:52] -// CHECK: 166:11: StringLiteral= Extent=[166:11 - 166:31] +// CHECK: 166:11: StringLiteral="warn_unused_result" Extent=[166:11 - 166:31] // CHECK: 166:33: DeclRefExpr=AT_warn_unused_result:29:22 Extent=[166:33 - 166:54] -// CHECK: 167:11: StringLiteral= Extent=[167:11 - 167:31] +// CHECK: 167:11: StringLiteral="carries_dependency" Extent=[167:11 - 167:31] // CHECK: 167:33: DeclRefExpr=AT_carries_dependency:17:7 Extent=[167:33 - 167:54] -// CHECK: 168:11: StringLiteral= Extent=[168:11 - 168:36] +// CHECK: 168:11: StringLiteral="ns_returns_not_retained" Extent=[168:11 - 168:36] // CHECK: 168:38: DeclRefExpr=AT_ns_returns_not_retained:24:7 Extent=[168:38 - 168:64] -// CHECK: 169:11: StringLiteral= Extent=[169:11 - 169:32] +// CHECK: 169:11: StringLiteral="ns_returns_retained" Extent=[169:11 - 169:32] // CHECK: 169:34: DeclRefExpr=AT_ns_returns_retained:24:35 Extent=[169:34 - 169:56] -// CHECK: 170:11: StringLiteral= Extent=[170:11 - 170:36] +// CHECK: 170:11: StringLiteral="cf_returns_not_retained" Extent=[170:11 - 170:36] // CHECK: 170:38: DeclRefExpr=AT_cf_returns_not_retained:23:7 Extent=[170:38 - 170:64] -// CHECK: 171:11: StringLiteral= Extent=[171:11 - 171:32] +// CHECK: 171:11: StringLiteral="cf_returns_retained" Extent=[171:11 - 171:32] // CHECK: 171:34: DeclRefExpr=AT_cf_returns_retained:23:35 Extent=[171:34 - 171:56] -// CHECK: 172:11: StringLiteral= Extent=[172:11 - 172:30] +// CHECK: 172:11: StringLiteral="ownership_returns" Extent=[172:11 - 172:30] // CHECK: 172:32: DeclRefExpr=AT_ownership_returns:25:44 Extent=[172:32 - 172:52] -// CHECK: 173:11: StringLiteral= Extent=[173:11 - 173:28] +// CHECK: 173:11: StringLiteral="ownership_holds" Extent=[173:11 - 173:28] // CHECK: 173:30: DeclRefExpr=AT_ownership_holds:25:24 Extent=[173:30 - 173:48] -// CHECK: 174:11: StringLiteral= Extent=[174:11 - 174:28] +// CHECK: 174:11: StringLiteral="ownership_takes" Extent=[174:11 - 174:28] // CHECK: 174:30: DeclRefExpr=AT_ownership_takes:26:7 Extent=[174:30 - 174:48] -// CHECK: 175:11: StringLiteral= Extent=[175:11 - 175:33] +// CHECK: 175:11: StringLiteral="reqd_work_group_size" Extent=[175:11 - 175:33] // CHECK: 175:35: DeclRefExpr=AT_reqd_wg_size:30:23 Extent=[175:35 - 175:50] -// CHECK: 176:11: StringLiteral= Extent=[176:11 - 176:26] +// CHECK: 176:11: StringLiteral="init_priority" Extent=[176:11 - 176:26] // CHECK: 176:28: DeclRefExpr=AT_init_priority:30:40 Extent=[176:28 - 176:44] -// CHECK: 177:11: StringLiteral= Extent=[177:11 - 177:35] +// CHECK: 177:11: StringLiteral="no_instrument_function" Extent=[177:11 - 177:35] // CHECK: 177:37: DeclRefExpr=AT_no_instrument_function:21:20 Extent=[177:37 - 177:62] -// CHECK: 178:11: StringLiteral= Extent=[178:11 - 178:21] +// CHECK: 178:11: StringLiteral="thiscall" Extent=[178:11 - 178:21] // CHECK: 178:23: DeclRefExpr=AT_thiscall:27:44 Extent=[178:23 - 178:34] -// CHECK: 179:11: StringLiteral= Extent=[179:11 - 179:19] +// CHECK: 179:11: StringLiteral="pascal" Extent=[179:11 - 179:19] // CHECK: 179:21: DeclRefExpr=AT_pascal:26:38 Extent=[179:21 - 179:30] -// CHECK: 180:11: StringLiteral= Extent=[180:11 - 180:20] +// CHECK: 180:11: StringLiteral="__cdecl" Extent=[180:11 - 180:20] // CHECK: 180:22: DeclRefExpr=AT_cdecl:17:30 Extent=[180:22 - 180:30] -// CHECK: 181:11: StringLiteral= Extent=[181:11 - 181:22] +// CHECK: 181:11: StringLiteral="__stdcall" Extent=[181:11 - 181:22] // CHECK: 181:24: DeclRefExpr=AT_stdcall:27:32 Extent=[181:24 - 181:34] -// CHECK: 182:11: StringLiteral= Extent=[182:11 - 182:23] +// CHECK: 182:11: StringLiteral="__fastcall" Extent=[182:11 - 182:23] // CHECK: 182:25: DeclRefExpr=AT_fastcall:19:27 Extent=[182:25 - 182:36] -// CHECK: 183:11: StringLiteral= Extent=[183:11 - 183:23] +// CHECK: 183:11: StringLiteral="__thiscall" Extent=[183:11 - 183:23] // CHECK: 183:25: DeclRefExpr=AT_thiscall:27:44 Extent=[183:25 - 183:36] -// CHECK: 184:11: StringLiteral= Extent=[184:11 - 184:21] +// CHECK: 184:11: StringLiteral="__pascal" Extent=[184:11 - 184:21] // CHECK: 184:23: DeclRefExpr=AT_pascal:26:38 Extent=[184:23 - 184:32] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 62de61e2b5..b5507a6349 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3398,6 +3398,22 @@ CXString clang_getCursorSpelling(CXCursor C) { } if (clang_isExpression(C.kind)) { + const Expr *E = getCursorExpr(C); + + if (C.kind == CXCursor_ObjCStringLiteral || + C.kind == CXCursor_StringLiteral) { + const StringLiteral *SLit; + if (const ObjCStringLiteral *OSL = dyn_cast(E)) { + SLit = OSL->getString(); + } else { + SLit = cast(E); + } + SmallString<256> Buf; + llvm::raw_svector_ostream OS(Buf); + SLit->outputString(OS); + return cxstring::createDup(OS.str()); + } + const Decl *D = getDeclFromExpr(getCursorExpr(C)); if (D) return getDeclSpelling(D); -- 2.40.0