Skip to content

Commit 50e23a5

Browse files
QuietMisdreavuszahiraam
authored andcommitted
ExtractAPI: use zero-based indices for line/column in symbol graph (llvm#71753)
Other implementations of the symbol graph format use zero-based indices for source locations, which causes problems when combined with clang's current one-based indices. This commit sets ExtractAPI's symbol graph output to use zero-based indices to align with other implementations. rdar://107639783
1 parent f00fa46 commit 50e23a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+442
-442
lines changed

clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ Object serializeSourcePosition(const PresumedLoc &Loc) {
109109
assert(Loc.isValid() && "invalid source position");
110110

111111
Object SourcePosition;
112-
SourcePosition["line"] = Loc.getLine();
113-
SourcePosition["character"] = Loc.getColumn();
112+
SourcePosition["line"] = Loc.getLine() - 1;
113+
SourcePosition["character"] = Loc.getColumn() - 1;
114114

115115
return SourcePosition;
116116
}

clang/test/ExtractAPI/anonymous_record_no_typedef.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ struct Vehicle {
105105
{
106106
"range": {
107107
"end": {
108-
"character": 29,
109-
"line": 3
108+
"character": 28,
109+
"line": 2
110110
},
111111
"start": {
112-
"character": 9,
113-
"line": 3
112+
"character": 8,
113+
"line": 2
114114
}
115115
},
116116
"text": "The type of vehicle."
@@ -127,8 +127,8 @@ struct Vehicle {
127127
},
128128
"location": {
129129
"position": {
130-
"character": 5,
131-
"line": 4
130+
"character": 4,
131+
"line": 3
132132
},
133133
"uri": "file://INPUT_DIR/input.h"
134134
},
@@ -163,8 +163,8 @@ struct Vehicle {
163163
},
164164
"location": {
165165
"position": {
166-
"character": 9,
167-
"line": 5
166+
"character": 8,
167+
"line": 4
168168
},
169169
"uri": "file://INPUT_DIR/input.h"
170170
},
@@ -206,8 +206,8 @@ struct Vehicle {
206206
},
207207
"location": {
208208
"position": {
209-
"character": 9,
210-
"line": 6
209+
"character": 8,
210+
"line": 5
211211
},
212212
"uri": "file://INPUT_DIR/input.h"
213213
},
@@ -256,12 +256,12 @@ struct Vehicle {
256256
{
257257
"range": {
258258
"end": {
259-
"character": 14,
260-
"line": 1
259+
"character": 13,
260+
"line": 0
261261
},
262262
"start": {
263-
"character": 5,
264-
"line": 1
263+
"character": 4,
264+
"line": 0
265265
}
266266
},
267267
"text": "A Vehicle"
@@ -278,8 +278,8 @@ struct Vehicle {
278278
},
279279
"location": {
280280
"position": {
281-
"character": 8,
282-
"line": 2
281+
"character": 7,
282+
"line": 1
283283
},
284284
"uri": "file://INPUT_DIR/input.h"
285285
},
@@ -332,8 +332,8 @@ struct Vehicle {
332332
},
333333
"location": {
334334
"position": {
335-
"character": 7,
336-
"line": 7
335+
"character": 6,
336+
"line": 6
337337
},
338338
"uri": "file://INPUT_DIR/input.h"
339339
},
@@ -387,8 +387,8 @@ struct Vehicle {
387387
},
388388
"location": {
389389
"position": {
390-
"character": 7,
391-
"line": 13
390+
"character": 6,
391+
"line": 12
392392
},
393393
"uri": "file://INPUT_DIR/input.h"
394394
},

clang/test/ExtractAPI/availability.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
9898
},
9999
"location": {
100100
"position": {
101-
"character": 6,
102-
"line": 1
101+
"character": 5,
102+
"line": 0
103103
},
104104
"uri": "file://INPUT_DIR/input.h"
105105
},
@@ -172,8 +172,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
172172
},
173173
"location": {
174174
"position": {
175-
"character": 6,
176-
"line": 3
175+
"character": 5,
176+
"line": 2
177177
},
178178
"uri": "file://INPUT_DIR/input.h"
179179
},
@@ -256,8 +256,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
256256
},
257257
"location": {
258258
"position": {
259-
"character": 6,
260-
"line": 5
259+
"character": 5,
260+
"line": 4
261261
},
262262
"uri": "file://INPUT_DIR/input.h"
263263
},
@@ -356,8 +356,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
356356
},
357357
"location": {
358358
"position": {
359-
"character": 6,
360-
"line": 7
359+
"character": 5,
360+
"line": 6
361361
},
362362
"uri": "file://INPUT_DIR/input.h"
363363
},
@@ -438,8 +438,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
438438
},
439439
"location": {
440440
"position": {
441-
"character": 6,
442-
"line": 9
441+
"character": 5,
442+
"line": 8
443443
},
444444
"uri": "file://INPUT_DIR/input.h"
445445
},

clang/test/ExtractAPI/bool.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ bool IsFoo(bool Bar);
7575
},
7676
"location": {
7777
"position": {
78-
"character": 6,
79-
"line": 2
78+
"character": 5,
79+
"line": 1
8080
},
8181
"uri": "file://INPUT_DIR/input.h"
8282
},
@@ -176,8 +176,8 @@ bool IsFoo(bool Bar);
176176
},
177177
"location": {
178178
"position": {
179-
"character": 6,
180-
"line": 4
179+
"character": 5,
180+
"line": 3
181181
},
182182
"uri": "file://INPUT_DIR/input.h"
183183
},

clang/test/ExtractAPI/bool.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ bool IsFoo(bool Bar);
7474
},
7575
"location": {
7676
"position": {
77-
"character": 6,
78-
"line": 1
77+
"character": 5,
78+
"line": 0
7979
},
8080
"uri": "file://INPUT_DIR/input.h"
8181
},
@@ -175,8 +175,8 @@ bool IsFoo(bool Bar);
175175
},
176176
"location": {
177177
"position": {
178-
"character": 6,
179-
"line": 3
178+
"character": 5,
179+
"line": 2
180180
},
181181
"uri": "file://INPUT_DIR/input.h"
182182
},

clang/test/ExtractAPI/class.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ class Foo {
106106
},
107107
"location": {
108108
"position": {
109-
"character": 7,
110-
"line": 1
109+
"character": 6,
110+
"line": 0
111111
},
112112
"uri": "file://INPUT_DIR/input.h"
113113
},
@@ -161,8 +161,8 @@ class Foo {
161161
},
162162
"location": {
163163
"position": {
164-
"character": 7,
165-
"line": 3
164+
"character": 6,
165+
"line": 2
166166
},
167167
"uri": "file://INPUT_DIR/input.h"
168168
},
@@ -225,8 +225,8 @@ class Foo {
225225
},
226226
"location": {
227227
"position": {
228-
"character": 15,
229-
"line": 4
228+
"character": 14,
229+
"line": 3
230230
},
231231
"uri": "file://INPUT_DIR/input.h"
232232
},
@@ -281,8 +281,8 @@ class Foo {
281281
},
282282
"location": {
283283
"position": {
284-
"character": 7,
285-
"line": 7
284+
"character": 6,
285+
"line": 6
286286
},
287287
"uri": "file://INPUT_DIR/input.h"
288288
},
@@ -337,8 +337,8 @@ class Foo {
337337
},
338338
"location": {
339339
"position": {
340-
"character": 7,
341-
"line": 10
340+
"character": 6,
341+
"line": 9
342342
},
343343
"uri": "file://INPUT_DIR/input.h"
344344
},

clang/test/ExtractAPI/class_template.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ template<typename T> class Foo {};
9696
},
9797
"location": {
9898
"position": {
99-
"character": 28,
100-
"line": 1
99+
"character": 27,
100+
"line": 0
101101
},
102102
"uri": "file://INPUT_DIR/input.h"
103103
},

clang/test/ExtractAPI/class_template_param_inheritance.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ template<typename T> class Foo : public T {};
103103
},
104104
"location": {
105105
"position": {
106-
"character": 28,
107-
"line": 1
106+
"character": 27,
107+
"line": 0
108108
},
109109
"uri": "file://INPUT_DIR/input.h"
110110
},

clang/test/ExtractAPI/class_template_partial_spec.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ template<typename Z> class Foo<Z, int> {};
114114
},
115115
"location": {
116116
"position": {
117-
"character": 40,
118-
"line": 1
117+
"character": 39,
118+
"line": 0
119119
},
120120
"uri": "file://INPUT_DIR/input.h"
121121
},
@@ -224,8 +224,8 @@ template<typename Z> class Foo<Z, int> {};
224224
},
225225
"location": {
226226
"position": {
227-
"character": 28,
228-
"line": 3
227+
"character": 27,
228+
"line": 2
229229
},
230230
"uri": "file://INPUT_DIR/input.h"
231231
},

clang/test/ExtractAPI/class_template_spec.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ template<> class Foo<int> {};
9898
},
9999
"location": {
100100
"position": {
101-
"character": 28,
102-
"line": 1
101+
"character": 27,
102+
"line": 0
103103
},
104104
"uri": "file://INPUT_DIR/input.h"
105105
},
@@ -178,8 +178,8 @@ template<> class Foo<int> {};
178178
},
179179
"location": {
180180
"position": {
181-
"character": 18,
182-
"line": 3
181+
"character": 17,
182+
"line": 2
183183
},
184184
"uri": "file://INPUT_DIR/input.h"
185185
},

clang/test/ExtractAPI/concept.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ template<typename T> concept Foo = true;
9696
},
9797
"location": {
9898
"position": {
99-
"character": 30,
100-
"line": 1
99+
"character": 29,
100+
"line": 0
101101
},
102102
"uri": "file://INPUT_DIR/input.h"
103103
},

clang/test/ExtractAPI/constructor_destructor.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class Foo {
8787
},
8888
"location": {
8989
"position": {
90-
"character": 7,
91-
"line": 1
90+
"character": 6,
91+
"line": 0
9292
},
9393
"uri": "file://INPUT_DIR/input.h"
9494
},
@@ -142,8 +142,8 @@ class Foo {
142142
},
143143
"location": {
144144
"position": {
145-
"character": 3,
146-
"line": 2
145+
"character": 2,
146+
"line": 1
147147
},
148148
"uri": "file://INPUT_DIR/input.h"
149149
},
@@ -198,8 +198,8 @@ class Foo {
198198
},
199199
"location": {
200200
"position": {
201-
"character": 3,
202-
"line": 3
201+
"character": 2,
202+
"line": 2
203203
},
204204
"uri": "file://INPUT_DIR/input.h"
205205
},

0 commit comments

Comments
 (0)