Skip to content

Commit

Permalink
ExtractAPI: use zero-based indices for line/column in symbol graph (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
QuietMisdreavus committed Nov 14, 2023
1 parent cc12449 commit 6353787
Show file tree
Hide file tree
Showing 52 changed files with 442 additions and 442 deletions.
4 changes: 2 additions & 2 deletions clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ Object serializeSourcePosition(const PresumedLoc &Loc) {
assert(Loc.isValid() && "invalid source position");

Object SourcePosition;
SourcePosition["line"] = Loc.getLine();
SourcePosition["character"] = Loc.getColumn();
SourcePosition["line"] = Loc.getLine() - 1;
SourcePosition["character"] = Loc.getColumn() - 1;

return SourcePosition;
}
Expand Down
40 changes: 20 additions & 20 deletions clang/test/ExtractAPI/anonymous_record_no_typedef.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ struct Vehicle {
{
"range": {
"end": {
"character": 29,
"line": 3
"character": 28,
"line": 2
},
"start": {
"character": 9,
"line": 3
"character": 8,
"line": 2
}
},
"text": "The type of vehicle."
Expand All @@ -127,8 +127,8 @@ struct Vehicle {
},
"location": {
"position": {
"character": 5,
"line": 4
"character": 4,
"line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -163,8 +163,8 @@ struct Vehicle {
},
"location": {
"position": {
"character": 9,
"line": 5
"character": 8,
"line": 4
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -206,8 +206,8 @@ struct Vehicle {
},
"location": {
"position": {
"character": 9,
"line": 6
"character": 8,
"line": 5
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -256,12 +256,12 @@ struct Vehicle {
{
"range": {
"end": {
"character": 14,
"line": 1
"character": 13,
"line": 0
},
"start": {
"character": 5,
"line": 1
"character": 4,
"line": 0
}
},
"text": "A Vehicle"
Expand All @@ -278,8 +278,8 @@ struct Vehicle {
},
"location": {
"position": {
"character": 8,
"line": 2
"character": 7,
"line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -332,8 +332,8 @@ struct Vehicle {
},
"location": {
"position": {
"character": 7,
"line": 7
"character": 6,
"line": 6
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -387,8 +387,8 @@ struct Vehicle {
},
"location": {
"position": {
"character": 7,
"line": 13
"character": 6,
"line": 12
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
20 changes: 10 additions & 10 deletions clang/test/ExtractAPI/availability.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
},
"location": {
"position": {
"character": 6,
"line": 1
"character": 5,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -172,8 +172,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
},
"location": {
"position": {
"character": 6,
"line": 3
"character": 5,
"line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -256,8 +256,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
},
"location": {
"position": {
"character": 6,
"line": 5
"character": 5,
"line": 4
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -356,8 +356,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
},
"location": {
"position": {
"character": 6,
"line": 7
"character": 5,
"line": 6
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -438,8 +438,8 @@ void e(void) __attribute__((availability(tvos, unavailable)));
},
"location": {
"position": {
"character": 6,
"line": 9
"character": 5,
"line": 8
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
8 changes: 4 additions & 4 deletions clang/test/ExtractAPI/bool.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
"character": 6,
"line": 2
"character": 5,
"line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -176,8 +176,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
"character": 6,
"line": 4
"character": 5,
"line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
8 changes: 4 additions & 4 deletions clang/test/ExtractAPI/bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
"character": 6,
"line": 1
"character": 5,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -175,8 +175,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
"character": 6,
"line": 3
"character": 5,
"line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
20 changes: 10 additions & 10 deletions clang/test/ExtractAPI/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ class Foo {
},
"location": {
"position": {
"character": 7,
"line": 1
"character": 6,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -161,8 +161,8 @@ class Foo {
},
"location": {
"position": {
"character": 7,
"line": 3
"character": 6,
"line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -225,8 +225,8 @@ class Foo {
},
"location": {
"position": {
"character": 15,
"line": 4
"character": 14,
"line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -281,8 +281,8 @@ class Foo {
},
"location": {
"position": {
"character": 7,
"line": 7
"character": 6,
"line": 6
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -337,8 +337,8 @@ class Foo {
},
"location": {
"position": {
"character": 7,
"line": 10
"character": 6,
"line": 9
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
4 changes: 2 additions & 2 deletions clang/test/ExtractAPI/class_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ template<typename T> class Foo {};
},
"location": {
"position": {
"character": 28,
"line": 1
"character": 27,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
4 changes: 2 additions & 2 deletions clang/test/ExtractAPI/class_template_param_inheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ template<typename T> class Foo : public T {};
},
"location": {
"position": {
"character": 28,
"line": 1
"character": 27,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
8 changes: 4 additions & 4 deletions clang/test/ExtractAPI/class_template_partial_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ template<typename Z> class Foo<Z, int> {};
},
"location": {
"position": {
"character": 40,
"line": 1
"character": 39,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -224,8 +224,8 @@ template<typename Z> class Foo<Z, int> {};
},
"location": {
"position": {
"character": 28,
"line": 3
"character": 27,
"line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
8 changes: 4 additions & 4 deletions clang/test/ExtractAPI/class_template_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ template<> class Foo<int> {};
},
"location": {
"position": {
"character": 28,
"line": 1
"character": 27,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -178,8 +178,8 @@ template<> class Foo<int> {};
},
"location": {
"position": {
"character": 18,
"line": 3
"character": 17,
"line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
4 changes: 2 additions & 2 deletions clang/test/ExtractAPI/concept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ template<typename T> concept Foo = true;
},
"location": {
"position": {
"character": 30,
"line": 1
"character": 29,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down
12 changes: 6 additions & 6 deletions clang/test/ExtractAPI/constructor_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class Foo {
},
"location": {
"position": {
"character": 7,
"line": 1
"character": 6,
"line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -142,8 +142,8 @@ class Foo {
},
"location": {
"position": {
"character": 3,
"line": 2
"character": 2,
"line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down Expand Up @@ -198,8 +198,8 @@ class Foo {
},
"location": {
"position": {
"character": 3,
"line": 3
"character": 2,
"line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
Expand Down

0 comments on commit 6353787

Please sign in to comment.