mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-30 22:06:05 +00:00

This extends ExtractAPI to take into account symbols defined in categories to types defined in an external module. This introduces 2 new command line flags, `--symbol-graph-dir=DIR` and `--emit-extension-symbol-graphs`, when used together this generates additional symbol graph files at `DIR/ExtendedModule@ProductName.symbols.json` for each external module that is extended in this way. Additionally this makes some cleanups to tests to make them more resilient and cleans up the `APISet` data structure.
372 lines
7.8 KiB
C++
372 lines
7.8 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 --pretty-sgf -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
|
|
class Foo {
|
|
template<typename T> void Bar(T Fizz);
|
|
|
|
template<> void Bar<int>(int Fizz);
|
|
};
|
|
|
|
/// 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": [
|
|
{
|
|
"kind": "memberOf",
|
|
"source": "c:@S@Foo@FT@>1#TBar#t0.0#v#",
|
|
"target": "c:@S@Foo",
|
|
"targetFallback": "Foo"
|
|
},
|
|
{
|
|
"kind": "memberOf",
|
|
"source": "c:@S@Foo@F@Bar<#I>#I#",
|
|
"target": "c:@S@Foo",
|
|
"targetFallback": "Foo"
|
|
}
|
|
],
|
|
"symbols": [
|
|
{
|
|
"accessLevel": "public",
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "class"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": ";"
|
|
}
|
|
],
|
|
"identifier": {
|
|
"interfaceLanguage": "c++",
|
|
"precise": "c:@S@Foo"
|
|
},
|
|
"kind": {
|
|
"displayName": "Class",
|
|
"identifier": "c++.class"
|
|
},
|
|
"location": {
|
|
"position": {
|
|
"character": 6,
|
|
"line": 0
|
|
},
|
|
"uri": "file://INPUT_DIR/input.h"
|
|
},
|
|
"names": {
|
|
"navigator": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
}
|
|
],
|
|
"subHeading": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Foo"
|
|
}
|
|
],
|
|
"title": "Foo"
|
|
},
|
|
"pathComponents": [
|
|
"Foo"
|
|
]
|
|
},
|
|
{
|
|
"accessLevel": "private",
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "template"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "<"
|
|
},
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "typename"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "genericParameter",
|
|
"spelling": "T"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "> "
|
|
},
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:v",
|
|
"spelling": "void"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Bar"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "("
|
|
},
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:t0.0",
|
|
"spelling": "T"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "internalParam",
|
|
"spelling": "Fizz"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": ");"
|
|
}
|
|
],
|
|
"functionSignature": {
|
|
"parameters": [
|
|
{
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:t0.0",
|
|
"spelling": "T"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "internalParam",
|
|
"spelling": "Fizz"
|
|
}
|
|
],
|
|
"name": "Fizz"
|
|
}
|
|
],
|
|
"returns": [
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:v",
|
|
"spelling": "void"
|
|
}
|
|
]
|
|
},
|
|
"identifier": {
|
|
"interfaceLanguage": "c++",
|
|
"precise": "c:@S@Foo@FT@>1#TBar#t0.0#v#"
|
|
},
|
|
"kind": {
|
|
"displayName": "Method Template",
|
|
"identifier": "c++.method"
|
|
},
|
|
"location": {
|
|
"position": {
|
|
"character": 28,
|
|
"line": 1
|
|
},
|
|
"uri": "file://INPUT_DIR/input.h"
|
|
},
|
|
"names": {
|
|
"navigator": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Bar"
|
|
}
|
|
],
|
|
"subHeading": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Bar"
|
|
}
|
|
],
|
|
"title": "Bar"
|
|
},
|
|
"pathComponents": [
|
|
"Foo",
|
|
"Bar"
|
|
],
|
|
"swiftGenerics": {
|
|
"parameters": [
|
|
{
|
|
"depth": 0,
|
|
"index": 0,
|
|
"name": "T"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"accessLevel": "private",
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "keyword",
|
|
"spelling": "template"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "<> "
|
|
},
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:v",
|
|
"spelling": "void"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Bar"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "<"
|
|
},
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:I",
|
|
"spelling": "int"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": ">("
|
|
},
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:I",
|
|
"spelling": "int"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "internalParam",
|
|
"spelling": "Fizz"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": ");"
|
|
}
|
|
],
|
|
"functionSignature": {
|
|
"parameters": [
|
|
{
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:I",
|
|
"spelling": "int"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "internalParam",
|
|
"spelling": "Fizz"
|
|
}
|
|
],
|
|
"name": "Fizz"
|
|
}
|
|
],
|
|
"returns": [
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:v",
|
|
"spelling": "void"
|
|
}
|
|
]
|
|
},
|
|
"identifier": {
|
|
"interfaceLanguage": "c++",
|
|
"precise": "c:@S@Foo@F@Bar<#I>#I#"
|
|
},
|
|
"kind": {
|
|
"displayName": "Method Template Specialization",
|
|
"identifier": "c++.method"
|
|
},
|
|
"location": {
|
|
"position": {
|
|
"character": 18,
|
|
"line": 3
|
|
},
|
|
"uri": "file://INPUT_DIR/input.h"
|
|
},
|
|
"names": {
|
|
"navigator": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Bar"
|
|
}
|
|
],
|
|
"subHeading": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "Bar"
|
|
}
|
|
],
|
|
"title": "Bar"
|
|
},
|
|
"pathComponents": [
|
|
"Foo",
|
|
"Bar"
|
|
]
|
|
}
|
|
]
|
|
}
|