Skip to content

Commit 61a844f

Browse files
[clang][ExtractAPI] Add targetFallback to relationships in symbol graph
Adds a 'targetFallback' field to relationships in symbol graph that contains the plain name of the relationship target. This is useful for clients when the relationship target symbol is not available. Differential Revision: https://reviews.llvm.org/D136455
1 parent bbf0402 commit 61a844f

File tree

9 files changed

+79
-39
lines changed

9 files changed

+79
-39
lines changed

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ void SymbolGraphSerializer::serializeRelationship(RelationshipKind Kind,
554554
Object Relationship;
555555
Relationship["source"] = Source.USR;
556556
Relationship["target"] = Target.USR;
557+
Relationship["targetFallback"] = Target.Name;
557558
Relationship["kind"] = getRelationshipString(Kind);
558559

559560
Relationships.emplace_back(std::move(Relationship));

clang/test/ExtractAPI/anonymous_record_no_typedef.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,26 @@ struct Vehicle {
5656
{
5757
"kind": "memberOf",
5858
"source": "c:@S@Vehicle@E@input.h@64@Bicycle",
59-
"target": "c:@S@Vehicle@[email protected]@64"
59+
"target": "c:@S@Vehicle@[email protected]@64",
60+
"targetFallback": "Vehicle::(anonymous)"
6061
},
6162
{
6263
"kind": "memberOf",
6364
"source": "c:@S@Vehicle@E@input.h@64@Car",
64-
"target": "c:@S@Vehicle@E@input.h@64"
65+
"target": "c:@S@Vehicle@E@input.h@64",
66+
"targetFallback": "Vehicle::(anonymous)"
6567
},
6668
{
6769
"kind": "memberOf",
6870
"source": "c:@S@Vehicle@FI@type",
69-
"target": "c:@S@Vehicle"
71+
"target": "c:@S@Vehicle",
72+
"targetFallback": "Vehicle"
7073
},
7174
{
7275
"kind": "memberOf",
7376
"source": "c:@S@Vehicle@FI@information",
74-
"target": "c:@S@Vehicle"
77+
"target": "c:@S@Vehicle",
78+
"targetFallback": "Vehicle"
7579
}
7680
],
7781
"symbols": [

clang/test/ExtractAPI/enum.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,57 +65,68 @@ enum {
6565
{
6666
"kind": "memberOf",
6767
"source": "c:@E@Vehicle@Bicycle",
68-
"target": "c:@E@Vehicle"
68+
"target": "c:@E@Vehicle",
69+
"targetFallback": "Vehicle"
6970
},
7071
{
7172
"kind": "memberOf",
7273
"source": "c:@E@Vehicle@Car",
73-
"target": "c:@E@Vehicle"
74+
"target": "c:@E@Vehicle",
75+
"targetFallback": "Vehicle"
7476
},
7577
{
7678
"kind": "memberOf",
7779
"source": "c:@E@Vehicle@Train",
78-
"target": "c:@E@Vehicle"
80+
"target": "c:@E@Vehicle",
81+
"targetFallback": "Vehicle"
7982
},
8083
{
8184
"kind": "memberOf",
8285
"source": "c:@E@Vehicle@Ship",
83-
"target": "c:@E@Vehicle"
86+
"target": "c:@E@Vehicle",
87+
"targetFallback": "Vehicle"
8488
},
8589
{
8690
"kind": "memberOf",
8791
"source": "c:@E@Vehicle@Airplane",
88-
"target": "c:@E@Vehicle"
92+
"target": "c:@E@Vehicle",
93+
"targetFallback": "Vehicle"
8994
},
9095
{
9196
"kind": "memberOf",
9297
"source": "c:@E@Direction@North",
93-
"target": "c:@E@Direction"
98+
"target": "c:@E@Direction",
99+
"targetFallback": "Direction"
94100
},
95101
{
96102
"kind": "memberOf",
97103
"source": "c:@E@Direction@East",
98-
"target": "c:@E@Direction"
104+
"target": "c:@E@Direction",
105+
"targetFallback": "Direction"
99106
},
100107
{
101108
"kind": "memberOf",
102109
"source": "c:@E@Direction@South",
103-
"target": "c:@E@Direction"
110+
"target": "c:@E@Direction",
111+
"targetFallback": "Direction"
104112
},
105113
{
106114
"kind": "memberOf",
107115
"source": "c:@E@Direction@West",
108-
"target": "c:@E@Direction"
116+
"target": "c:@E@Direction",
117+
"targetFallback": "Direction"
109118
},
110119
{
111120
"kind": "memberOf",
112121
"source": "c:@Ea@Constant@Constant",
113-
"target": "c:@Ea@Constant"
122+
"target": "c:@Ea@Constant",
123+
"targetFallback": "(anonymous)"
114124
},
115125
{
116126
"kind": "memberOf",
117127
"source": "c:@Ea@OtherConstant@OtherConstant",
118-
"target": "c:@Ea@OtherConstant"
128+
"target": "c:@Ea@OtherConstant",
129+
"targetFallback": "(anonymous)"
119130
}
120131
],
121132
"symbols": [

clang/test/ExtractAPI/objc_category.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,26 @@ + (void)ClassMethod;
5454
{
5555
"kind": "memberOf",
5656
"source": "c:objc(cs)Interface(im)InstanceMethod",
57-
"target": "c:objc(cs)Interface"
57+
"target": "c:objc(cs)Interface",
58+
"targetFallback": "Interface"
5859
},
5960
{
6061
"kind": "memberOf",
6162
"source": "c:objc(cs)Interface(cm)ClassMethod",
62-
"target": "c:objc(cs)Interface"
63+
"target": "c:objc(cs)Interface",
64+
"targetFallback": "Interface"
6365
},
6466
{
6567
"kind": "memberOf",
6668
"source": "c:objc(cs)Interface(py)Property",
67-
"target": "c:objc(cs)Interface"
69+
"target": "c:objc(cs)Interface",
70+
"targetFallback": "Interface"
6871
},
6972
{
7073
"kind": "conformsTo",
7174
"source": "c:objc(cs)Interface",
72-
"target": "c:objc(pl)Protocol"
75+
"target": "c:objc(pl)Protocol",
76+
"targetFallback": "Protocol"
7377
}
7478
],
7579
"symbols": [

clang/test/ExtractAPI/objc_interface.m

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,44 @@ - (char)getIvar;
5757
{
5858
"kind": "memberOf",
5959
"source": "c:objc(cs)Super(cm)getWithProperty:",
60-
"target": "c:objc(cs)Super"
60+
"target": "c:objc(cs)Super",
61+
"targetFallback": "Super"
6162
},
6263
{
6364
"kind": "memberOf",
6465
"source": "c:objc(cs)Super(im)setProperty:andOtherThing:",
65-
"target": "c:objc(cs)Super"
66+
"target": "c:objc(cs)Super",
67+
"targetFallback": "Super"
6668
},
6769
{
6870
"kind": "memberOf",
6971
"source": "c:objc(cs)Super(py)Property",
70-
"target": "c:objc(cs)Super"
72+
"target": "c:objc(cs)Super",
73+
"targetFallback": "Super"
7174
},
7275
{
7376
"kind": "conformsTo",
7477
"source": "c:objc(cs)Super",
75-
"target": "c:objc(pl)Protocol"
78+
"target": "c:objc(pl)Protocol",
79+
"targetFallback": "Protocol"
7680
},
7781
{
7882
"kind": "memberOf",
7983
"source": "c:objc(cs)Derived@Ivar",
80-
"target": "c:objc(cs)Derived"
84+
"target": "c:objc(cs)Derived",
85+
"targetFallback": "Derived"
8186
},
8287
{
8388
"kind": "memberOf",
8489
"source": "c:objc(cs)Derived(im)getIvar",
85-
"target": "c:objc(cs)Derived"
90+
"target": "c:objc(cs)Derived",
91+
"targetFallback": "Derived"
8692
},
8793
{
8894
"kind": "inheritsFrom",
8995
"source": "c:objc(cs)Derived",
90-
"target": "c:objc(cs)Super"
96+
"target": "c:objc(cs)Super",
97+
"targetFallback": "Super"
9198
}
9299
],
93100
"symbols": [

clang/test/ExtractAPI/objc_property.m

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,44 @@ @interface Interface (Category) <Protocol>
5555
{
5656
"kind": "memberOf",
5757
"source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp",
58-
"target": "c:objc(cs)Interface"
58+
"target": "c:objc(cs)Interface",
59+
"targetFallback": "Interface"
5960
},
6061
{
6162
"kind": "memberOf",
6263
"source": "c:objc(cs)Interface(py)myInterfaceInstanceProp",
63-
"target": "c:objc(cs)Interface"
64+
"target": "c:objc(cs)Interface",
65+
"targetFallback": "Interface"
6466
},
6567
{
6668
"kind": "memberOf",
6769
"source": "c:objc(cs)Interface(cpy)myCategoryTypeProp",
68-
"target": "c:objc(cs)Interface"
70+
"target": "c:objc(cs)Interface",
71+
"targetFallback": "Interface"
6972
},
7073
{
7174
"kind": "memberOf",
7275
"source": "c:objc(cs)Interface(py)myCategoryInstanceProp",
73-
"target": "c:objc(cs)Interface"
76+
"target": "c:objc(cs)Interface",
77+
"targetFallback": "Interface"
7478
},
7579
{
7680
"kind": "conformsTo",
7781
"source": "c:objc(cs)Interface",
78-
"target": "c:objc(pl)Protocol"
82+
"target": "c:objc(pl)Protocol",
83+
"targetFallback": "Protocol"
7984
},
8085
{
8186
"kind": "memberOf",
8287
"source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp",
83-
"target": "c:objc(pl)Protocol"
88+
"target": "c:objc(pl)Protocol",
89+
"targetFallback": "Protocol"
8490
},
8591
{
8692
"kind": "memberOf",
8793
"source": "c:objc(pl)Protocol(py)myProtocolInstanceProp",
88-
"target": "c:objc(pl)Protocol"
94+
"target": "c:objc(pl)Protocol",
95+
"targetFallback": "Protocol"
8996
}
9097
],
9198
"symbols": [

clang/test/ExtractAPI/objc_protocol.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ @protocol AnotherProtocol <Protocol>
4949
{
5050
"kind": "conformsTo",
5151
"source": "c:objc(pl)AnotherProtocol",
52-
"target": "c:objc(pl)Protocol"
52+
"target": "c:objc(pl)Protocol",
53+
"targetFallback": "Protocol"
5354
}
5455
],
5556
"symbols": [

clang/test/ExtractAPI/struct.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,26 @@ struct Color {
5252
{
5353
"kind": "memberOf",
5454
"source": "c:@S@Color@FI@Red",
55-
"target": "c:@S@Color"
55+
"target": "c:@S@Color",
56+
"targetFallback": "Color"
5657
},
5758
{
5859
"kind": "memberOf",
5960
"source": "c:@S@Color@FI@Green",
60-
"target": "c:@S@Color"
61+
"target": "c:@S@Color",
62+
"targetFallback": "Color"
6163
},
6264
{
6365
"kind": "memberOf",
6466
"source": "c:@S@Color@FI@Blue",
65-
"target": "c:@S@Color"
67+
"target": "c:@S@Color",
68+
"targetFallback": "Color"
6669
},
6770
{
6871
"kind": "memberOf",
6972
"source": "c:@S@Color@FI@Alpha",
70-
"target": "c:@S@Color"
73+
"target": "c:@S@Color",
74+
"targetFallback": "Color"
7175
}
7276
],
7377
"symbols": [

clang/test/ExtractAPI/underscored.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ typedef _HiddenTypedef ExposedTypedefToHidden;
6565
{
6666
"kind": "memberOf",
6767
"source": "c:@S@ExposedRecord@FI@a",
68-
"target": "c:@S@ExposedRecord"
68+
"target": "c:@S@ExposedRecord",
69+
"targetFallback": "ExposedRecord"
6970
}
7071
],
7172
"symbols": [

0 commit comments

Comments
 (0)