-
Notifications
You must be signed in to change notification settings - Fork 14.3k
ExtractAPI: use zero-based indices for line/column in symbol graph #71753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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
@llvm/pr-subscribers-clang Author: QuietMisdreavus (QuietMisdreavus) ChangesOther 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 Patch is 67.53 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/71753.diff 52 Files Affected:
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 3c8668d26c60b76..1bc10b32322890e 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -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;
}
diff --git a/clang/test/ExtractAPI/anonymous_record_no_typedef.c b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
index 0890e3cbdb6d085..0e50f4a0948c94a 100644
--- a/clang/test/ExtractAPI/anonymous_record_no_typedef.c
+++ b/clang/test/ExtractAPI/anonymous_record_no_typedef.c
@@ -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."
@@ -127,8 +127,8 @@ struct Vehicle {
},
"location": {
"position": {
- "character": 5,
- "line": 4
+ "character": 4,
+ "line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -163,8 +163,8 @@ struct Vehicle {
},
"location": {
"position": {
- "character": 9,
- "line": 5
+ "character": 8,
+ "line": 4
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -206,8 +206,8 @@ struct Vehicle {
},
"location": {
"position": {
- "character": 9,
- "line": 6
+ "character": 8,
+ "line": 5
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -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"
@@ -278,8 +278,8 @@ struct Vehicle {
},
"location": {
"position": {
- "character": 8,
- "line": 2
+ "character": 7,
+ "line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -332,8 +332,8 @@ struct Vehicle {
},
"location": {
"position": {
- "character": 7,
- "line": 7
+ "character": 6,
+ "line": 6
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -387,8 +387,8 @@ struct Vehicle {
},
"location": {
"position": {
- "character": 7,
- "line": 13
+ "character": 6,
+ "line": 12
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/availability.c b/clang/test/ExtractAPI/availability.c
index 0c8cd3629f3fdee..aa6766c96b4f334 100644
--- a/clang/test/ExtractAPI/availability.c
+++ b/clang/test/ExtractAPI/availability.c
@@ -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"
},
@@ -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"
},
@@ -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"
},
@@ -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"
},
@@ -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"
},
diff --git a/clang/test/ExtractAPI/bool.c b/clang/test/ExtractAPI/bool.c
index fc013792c679914..f4082edeb02ede4 100644
--- a/clang/test/ExtractAPI/bool.c
+++ b/clang/test/ExtractAPI/bool.c
@@ -75,8 +75,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
- "character": 6,
- "line": 2
+ "character": 5,
+ "line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -176,8 +176,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
- "character": 6,
- "line": 4
+ "character": 5,
+ "line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/bool.cpp b/clang/test/ExtractAPI/bool.cpp
index 88f753c98876482..1b445e220a4a0eb 100644
--- a/clang/test/ExtractAPI/bool.cpp
+++ b/clang/test/ExtractAPI/bool.cpp
@@ -74,8 +74,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
- "character": 6,
- "line": 1
+ "character": 5,
+ "line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -175,8 +175,8 @@ bool IsFoo(bool Bar);
},
"location": {
"position": {
- "character": 6,
- "line": 3
+ "character": 5,
+ "line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/class.cpp b/clang/test/ExtractAPI/class.cpp
index 4a88029aeb0554c..21cac43057524ad 100644
--- a/clang/test/ExtractAPI/class.cpp
+++ b/clang/test/ExtractAPI/class.cpp
@@ -106,8 +106,8 @@ class Foo {
},
"location": {
"position": {
- "character": 7,
- "line": 1
+ "character": 6,
+ "line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -161,8 +161,8 @@ class Foo {
},
"location": {
"position": {
- "character": 7,
- "line": 3
+ "character": 6,
+ "line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -225,8 +225,8 @@ class Foo {
},
"location": {
"position": {
- "character": 15,
- "line": 4
+ "character": 14,
+ "line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -281,8 +281,8 @@ class Foo {
},
"location": {
"position": {
- "character": 7,
- "line": 7
+ "character": 6,
+ "line": 6
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -337,8 +337,8 @@ class Foo {
},
"location": {
"position": {
- "character": 7,
- "line": 10
+ "character": 6,
+ "line": 9
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/class_template.cpp b/clang/test/ExtractAPI/class_template.cpp
index 25895a6fefe06d6..b04dca6bffda161 100644
--- a/clang/test/ExtractAPI/class_template.cpp
+++ b/clang/test/ExtractAPI/class_template.cpp
@@ -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"
},
diff --git a/clang/test/ExtractAPI/class_template_param_inheritance.cpp b/clang/test/ExtractAPI/class_template_param_inheritance.cpp
index 0e50e6081c914dc..0d38fd1b7f53064 100644
--- a/clang/test/ExtractAPI/class_template_param_inheritance.cpp
+++ b/clang/test/ExtractAPI/class_template_param_inheritance.cpp
@@ -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"
},
diff --git a/clang/test/ExtractAPI/class_template_partial_spec.cpp b/clang/test/ExtractAPI/class_template_partial_spec.cpp
index 294bbb726bcf08c..eba069319ce450a 100644
--- a/clang/test/ExtractAPI/class_template_partial_spec.cpp
+++ b/clang/test/ExtractAPI/class_template_partial_spec.cpp
@@ -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"
},
@@ -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"
},
diff --git a/clang/test/ExtractAPI/class_template_spec.cpp b/clang/test/ExtractAPI/class_template_spec.cpp
index 166b03911db7dc3..4b183cbb844580c 100644
--- a/clang/test/ExtractAPI/class_template_spec.cpp
+++ b/clang/test/ExtractAPI/class_template_spec.cpp
@@ -98,8 +98,8 @@ template<> class Foo<int> {};
},
"location": {
"position": {
- "character": 28,
- "line": 1
+ "character": 27,
+ "line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -178,8 +178,8 @@ template<> class Foo<int> {};
},
"location": {
"position": {
- "character": 18,
- "line": 3
+ "character": 17,
+ "line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/concept.cpp b/clang/test/ExtractAPI/concept.cpp
index 08c3c832ce3a068..ff4e71026e72834 100644
--- a/clang/test/ExtractAPI/concept.cpp
+++ b/clang/test/ExtractAPI/concept.cpp
@@ -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"
},
diff --git a/clang/test/ExtractAPI/constructor_destructor.cpp b/clang/test/ExtractAPI/constructor_destructor.cpp
index 65a924b53d69cbf..9742d4bae261334 100644
--- a/clang/test/ExtractAPI/constructor_destructor.cpp
+++ b/clang/test/ExtractAPI/constructor_destructor.cpp
@@ -87,8 +87,8 @@ class Foo {
},
"location": {
"position": {
- "character": 7,
- "line": 1
+ "character": 6,
+ "line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -142,8 +142,8 @@ class Foo {
},
"location": {
"position": {
- "character": 3,
- "line": 2
+ "character": 2,
+ "line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -198,8 +198,8 @@ class Foo {
},
"location": {
"position": {
- "character": 3,
- "line": 3
+ "character": 2,
+ "line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/conversions.cpp b/clang/test/ExtractAPI/conversions.cpp
index 326c84877ca7dae..fc8d0675443730c 100644
--- a/clang/test/ExtractAPI/conversions.cpp
+++ b/clang/test/ExtractAPI/conversions.cpp
@@ -87,8 +87,8 @@ class Foo {
},
"location": {
"position": {
- "character": 7,
- "line": 1
+ "character": 6,
+ "line": 0
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -150,8 +150,8 @@ class Foo {
},
"location": {
"position": {
- "character": 3,
- "line": 2
+ "character": 2,
+ "line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -222,8 +222,8 @@ class Foo {
},
"location": {
"position": {
- "character": 12,
- "line": 3
+ "character": 11,
+ "line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
diff --git a/clang/test/ExtractAPI/emit-symbol-graph/multi_file.c b/clang/test/ExtractAPI/emit-symbol-graph/multi_file.c
index 1b44cfbdeb75a98..e6b72d5881e7d19 100644
--- a/clang/test/ExtractAPI/emit-symbol-graph/multi_file.c
+++ b/clang/test/ExtractAPI/emit-symbol-graph/multi_file.c
@@ -183,8 +183,8 @@ int main ()
},
"location": {
"position": {
- "character": 5,
- "line": 7
+ "character": 4,
+ "line": 6
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -247,8 +247,8 @@ int main ()
},
"location": {
"position": {
- "character": 6,
- "line": 8
+ "character": 5,
+ "line": 7
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -311,8 +311,8 @@ int main ()
},
"location": {
"position": {
- "character": 5,
- "line": 3
+ "character": 4,
+ "line": 2
},
"uri": "file://INPUT_DIR/main.c"
},
@@ -361,8 +361,8 @@ int main ()
},
"location": {
"position": {
- "character": 9,
- "line": 4
+ "character": 8,
+ "line": 3
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -411,8 +411,8 @@ int main ()
},
"location": {
"position": {
- "character": 9,
- "line": 5
+ "character": 8,
+ "line": 4
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -571,8 +571,8 @@ int main ()
},
"location": {
"position": {
- "character": 5,
- "line": 7
+ "character": 4,
+ "line": 6
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -635,8 +635,8 @@ int main ()
},
"location": {
"position": {
- "character": 6,
- "line": 8
+ "character": 5,
+ "line": 7
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -685,8 +685,8 @@ int main ()
},
"location": {
"position": {
- "character": 9,
- "line": 4
+ "character": 8,
+ "line": 3
},
"uri": "file://INPUT_DIR/test.h"
},
@@ -735,8 +735,8 @@ int main ()
},
"location": {
"position": {
- "character": 9,
- "line": 5
+ "character": 8,
+ "line": 4
},
"uri": "file://INPUT_DIR/test.h"
},
diff --git a/clang/test/ExtractAPI/emit-symbol-graph/single_file.c b/clang/test/ExtractAPI/emit-symbol-graph/single_file.c
index aa2a5353ae980bc..8599e82e10783aa 100644
--- a/clang/test/ExtractAPI/emit-symbol-graph/single_file.c
+++ b/clang/test/ExtractAPI/emit-symbol-graph/single_file.c
@@ -85,8 +85,8 @@ int main ()
},
"location": {
"position": {
- "character": 5,
- "line": 4
+ "character": 4,
+ "line": 3
},
"uri": "file://INPUT_DIR/main.c"
},
@@ -135,8 +135,8 @@ int main ()
},
"location": {
"position": {
- "character": 9,
- "line": 1
+ "character": 8,
+ "line": 0
},
"uri": "file://INPUT_DIR/main.c"
},
@@ -185,8 +185,8 @@ int main ()
},
"location": {
"position": {
- "character": 9,
- "line": 2
+ "character": 8,
+ "line": 1
},
"uri": "file://INPUT_DIR/main.c"
},
diff --git a/clang/test/ExtractAPI/enum.c b/clang/test/ExtractAPI/enum.c
index a6c749028bd17b3..94499d9fc3a6397 100644
--- a/clang/test/ExtractAPI/enum.c
+++ b/clang/test/ExtractAPI/enum.c
@@ -164,12 +164,12 @@ enum {
{
"range": {
"end": {
- "character": 22,
- "line": 1
+ "character": 21,
+ "line": 0
},
"start": {
- "character": 5,
- "line": 1
+ "character": 4,
+ "line": 0
}
},
"text": "Kinds of vehicles"
@@ -186,8 +186,8 @@ enum {
},
"location": {
"position": {
- "character": 6,
- "line": 2
+ "character": 5,
+ "line": 1
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -228,8 +228,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 3
+ "character": 2,
+ "line": 2
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -271,8 +271,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 4
+ "character": 2,
+ "line": 3
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -309,12 +309,12 @@ enum {
{
"range": {
"end": {
- "character": 45,
- "line": 5
+ "character": 44,
+ "line": 4
},
"start": {
- "character": 15,
- "line": 5
+ "character": 14,
+ "line": 4
}
},
"text": "Move this to the top! -Sheldon"
@@ -331,8 +331,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 5
+ "character": 2,
+ "line": 4
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -374,8 +374,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 6
+ "character": 2,
+ "line": 5
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -417,8 +417,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 7
+ "character": 2,
+ "line": 6
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -481,8 +481,8 @@ enum {
},
"location": {
"position": {
- "character": 6,
- "line": 10
+ "character": 5,
+ "line": 9
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -523,8 +523,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 11
+ "character": 2,
+ "line": 10
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -566,8 +566,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 12
+ "character": 2,
+ "line": 11
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -609,8 +609,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 13
+ "character": 2,
+ "line": 12
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -652,8 +652,8 @@ enum {
},
"location": {
"position": {
- "character": 3,
- "line": 14
+ "character": 2,
+ "line": 13
},
"uri": "file://INPUT_DIR/input.h"
},
@@ -708,8 +708,...
[truncated]
|
An unfortunate side effect of changing the source location representation is that it required changing almost all the ExtractAPI tests. 😅 But the overall diff is rather small. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…lvm#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
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. Cherry-picked from llvm#71753. rdar://107639783
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. Cherry-picked from llvm#71753. rdar://107639783
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