mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-13 17:37:00 +00:00

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
207 lines
4.2 KiB
C++
207 lines
4.2 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
|
|
// RUN: %t/reference.output.json.in >> %t/reference.output.json
|
|
// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
|
|
// RUN: -x c++-header %t/input.h -o %t/output.json -verify
|
|
|
|
// Generator version is not consistent across test runs, normalize it.
|
|
// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
|
|
// RUN: %t/output.json >> %t/output-normalized.json
|
|
// RUN: diff %t/reference.output.json %t/output-normalized.json
|
|
|
|
//--- input.h
|
|
template<typename T> class Foo {};
|
|
|
|
template<> class Foo<int> {};
|
|
|
|
/// expected-no-diagnostics
|
|
|
|
//--- reference.output.json.in
|
|
{
|
|
"metadata": {
|
|
"formatVersion": {
|
|
"major": 0,
|
|
"minor": 5,
|
|
"patch": 3
|
|
},
|
|
"generator": "?"
|
|
},
|
|
"module": {
|
|
"name": "",
|
|
"platform": {
|
|
"architecture": "arm64",
|
|
"operatingSystem": {
|
|
"minimumVersion": {
|
|
"major": 11,
|
|
"minor": 0,
|
|
"patch": 0
|
|
},
|
|
"name": "macosx"
|
|
},
|
|
"vendor": "apple"
|
|
}
|
|
},
|
|
"relationships": [],
|
|
"symbols": [
|
|
{
|
|
"accessLevel": "public",
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "template"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "<"
|
|
},
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "typename"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "genericParameter",
|
|
"spelling": "T"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "> "
|
|
},
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "class"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": ";"
|
|
}
|
|
],
|
|
"identifier": {
|
|
"interfaceLanguage": "c++",
|
|
"precise": "c:@ST>1#T@Foo"
|
|
},
|
|
"kind": {
|
|
"displayName": "Class",
|
|
"identifier": "c++.class"
|
|
},
|
|
"location": {
|
|
"position": {
|
|
"character": 27,
|
|
"line": 0
|
|
},
|
|
"uri": "file://INPUT_DIR/input.h"
|
|
},
|
|
"names": {
|
|
"navigator": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
}
|
|
],
|
|
"subHeading": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
}
|
|
],
|
|
"title": "Foo"
|
|
},
|
|
"pathComponents": [
|
|
"Foo"
|
|
],
|
|
"swiftGenerics": {
|
|
"parameters": [
|
|
{
|
|
"depth": 0,
|
|
"index": 0,
|
|
"name": "T"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"accessLevel": "public",
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "template"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "<> "
|
|
},
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "class"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "<"
|
|
},
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:I",
|
|
"spelling": "int"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": ">;"
|
|
}
|
|
],
|
|
"identifier": {
|
|
"interfaceLanguage": "c++",
|
|
"precise": "c:@S@Foo>#I"
|
|
},
|
|
"kind": {
|
|
"displayName": "Class",
|
|
"identifier": "c++.class"
|
|
},
|
|
"location": {
|
|
"position": {
|
|
"character": 17,
|
|
"line": 2
|
|
},
|
|
"uri": "file://INPUT_DIR/input.h"
|
|
},
|
|
"names": {
|
|
"navigator": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
}
|
|
],
|
|
"subHeading": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
}
|
|
],
|
|
"title": "Foo"
|
|
},
|
|
"pathComponents": [
|
|
"Foo"
|
|
]
|
|
}
|
|
]
|
|
}
|