
Extension SGFs require the module system to be enabled in order to discover which module defines the extended external type. This patch ensures the following: - Associate symbols with their top level module name, and that only top level modules are considered as modules for emitting extension SGFs. - Ensure we don't drop macro definitions that came from a submodule. To this end look at all defined macros in `PPCalbacks::EndOfMainFile` instead of relying on `PPCallbacks::MacroDefined` being called to detect a macro definition.
112 lines
2.4 KiB
C
112 lines
2.4 KiB
C
// RUN: rm -rf %t
|
|
// RUN: mkdir %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 %t/main.c -emit-symbol-graph --pretty-sgf \
|
|
// RUN: --symbol-graph-dir=%t/SymbolGraphs --product-name=basicfile -triple=x86_64-apple-macosx12.0.0
|
|
|
|
// Generator version is not consistent across test runs, normalize it.
|
|
// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
|
|
// RUN: %t/SymbolGraphs/main.c.symbols.json >> %t/output-normalized.json
|
|
// RUN: diff %t/reference.output.json %t/output-normalized.json
|
|
|
|
// CHECK-NOT: error:
|
|
// CHECK-NOT: warning:
|
|
|
|
//--- main.c
|
|
int main ()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
//--- reference.output.json.in
|
|
{
|
|
"metadata": {
|
|
"formatVersion": {
|
|
"major": 0,
|
|
"minor": 5,
|
|
"patch": 3
|
|
},
|
|
"generator": "?"
|
|
},
|
|
"module": {
|
|
"name": "basicfile",
|
|
"platform": {
|
|
"architecture": "x86_64",
|
|
"operatingSystem": {
|
|
"name": "macosx"
|
|
},
|
|
"vendor": "apple"
|
|
}
|
|
},
|
|
"relationships": [],
|
|
"symbols": [
|
|
{
|
|
"accessLevel": "public",
|
|
"declarationFragments": [
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:I",
|
|
"spelling": "int"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": " "
|
|
},
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "main"
|
|
},
|
|
{
|
|
"kind": "text",
|
|
"spelling": "();"
|
|
}
|
|
],
|
|
"functionSignature": {
|
|
"returns": [
|
|
{
|
|
"kind": "typeIdentifier",
|
|
"preciseIdentifier": "c:I",
|
|
"spelling": "int"
|
|
}
|
|
]
|
|
},
|
|
"identifier": {
|
|
"interfaceLanguage": "c",
|
|
"precise": "c:@F@main"
|
|
},
|
|
"kind": {
|
|
"displayName": "Function",
|
|
"identifier": "c.func"
|
|
},
|
|
"location": {
|
|
"position": {
|
|
"character": 4,
|
|
"line": 0
|
|
},
|
|
"uri": "file://INPUT_DIR/main.c"
|
|
},
|
|
"names": {
|
|
"navigator": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "main"
|
|
}
|
|
],
|
|
"subHeading": [
|
|
{
|
|
"kind": "identifier",
|
|
"spelling": "main"
|
|
}
|
|
],
|
|
"title": "main"
|
|
},
|
|
"pathComponents": [
|
|
"main"
|
|
]
|
|
}
|
|
]
|
|
}
|