mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
ABIChecker: include module name explicitly in generated ABI baseline. NFC
This commit is contained in:
@@ -438,7 +438,7 @@ class SDKNodeRoot: public SDKNode {
|
||||
uint8_t JsonFormatVer;
|
||||
public:
|
||||
SDKNodeRoot(SDKNodeInitInfo Info);
|
||||
static SDKNode *getInstance(SDKContext &Ctx);
|
||||
static SDKNode *getInstance(SDKContext &Ctx, ArrayRef<ModuleDecl*> modules);
|
||||
static bool classof(const SDKNode *N);
|
||||
void registerDescendant(SDKNode *D);
|
||||
virtual void jsonize(json::Output &Out) override;
|
||||
@@ -777,8 +777,7 @@ public:
|
||||
void visitAllRoots(SDKNodeVisitor &Visitor) {
|
||||
SDKNode::preorderVisit(RootNode, Visitor);
|
||||
}
|
||||
SwiftDeclCollector(SDKContext &Ctx) : Ctx(Ctx),
|
||||
RootNode(SDKNodeRoot::getInstance(Ctx)) {}
|
||||
SwiftDeclCollector(SDKContext &Ctx, ArrayRef<ModuleDecl*> modules = {});
|
||||
|
||||
// Construct all roots vector from a given file where a forest was
|
||||
// previously dumped.
|
||||
@@ -818,8 +817,6 @@ public:
|
||||
void foundDecl(ValueDecl *VD, DeclVisibilityKind Reason,
|
||||
DynamicLookupInfo dynamicLookupInfo = {}) override;
|
||||
void processDecl(Decl *D);
|
||||
public:
|
||||
void lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules);
|
||||
};
|
||||
|
||||
void detectRename(SDKNode *L, SDKNode *R);
|
||||
|
||||
@@ -428,10 +428,17 @@ StringRef SDKNodeType::getTypeRoleDescription() const {
|
||||
llvm_unreachable("Unhandled SDKNodeKind in switch");
|
||||
}
|
||||
|
||||
SDKNode *SDKNodeRoot::getInstance(SDKContext &Ctx) {
|
||||
SDKNode *SDKNodeRoot::getInstance(SDKContext &Ctx, ArrayRef<ModuleDecl*> modules) {
|
||||
SDKNodeInitInfo Info(Ctx);
|
||||
Info.Name = Ctx.buffer("TopLevel");
|
||||
Info.PrintedName = Ctx.buffer("TopLevel");
|
||||
StringRef name = Ctx.buffer("NO_MODULE");
|
||||
if (modules.size() == 1) {
|
||||
// use the module name
|
||||
name = Ctx.buffer(modules[0]->getName().str());
|
||||
} else if (!modules.empty()) {
|
||||
name = Ctx.buffer("MULTI_MODULES");
|
||||
}
|
||||
Info.Name = name;
|
||||
Info.PrintedName = name;
|
||||
llvm::transform(Ctx.getOpts().ToolArgs, std::back_inserter(Info.ToolArgs),
|
||||
[&](std::string s) { return Ctx.buffer(s); });
|
||||
Info.JsonFormatVer = DIGESTER_JSON_VERSION;
|
||||
@@ -1976,8 +1983,13 @@ void SwiftDeclCollector::printTopLevelNames() {
|
||||
llvm::outs() << Node->getKind() << ": " << Node->getName() << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
void SwiftDeclCollector::lookupVisibleDecls(ArrayRef<ModuleDecl *> Modules) {
|
||||
SwiftDeclCollector::SwiftDeclCollector(SDKContext &Ctx,
|
||||
ArrayRef<ModuleDecl*> Modules) : Ctx(Ctx),
|
||||
RootNode(SDKNodeRoot::getInstance(Ctx, Modules)) {
|
||||
if (Modules.empty()) {
|
||||
return;
|
||||
}
|
||||
assert(!Modules.empty());
|
||||
for (auto M: Modules) {
|
||||
llvm::SmallVector<Decl*, 512> Decls;
|
||||
swift::getTopLevelDeclsForDisplay(M, Decls);
|
||||
@@ -2544,8 +2556,7 @@ swift::ide::api::getSDKNodeRoot(SDKContext &SDKCtx,
|
||||
if (Opts.Verbose)
|
||||
llvm::errs() << "Scanning symbols...\n";
|
||||
|
||||
SwiftDeclCollector Collector(SDKCtx);
|
||||
Collector.lookupVisibleDecls(Modules);
|
||||
SwiftDeclCollector Collector(SDKCtx, Modules);
|
||||
return Collector.getSDKRoot();
|
||||
}
|
||||
|
||||
@@ -2603,7 +2614,11 @@ void swift::ide::api::dumpModuleContent(ModuleDecl *MD, llvm::raw_ostream &os,
|
||||
opts.SkipRemoveDeprecatedCheck = false;
|
||||
opts.Verbose = false;
|
||||
SDKContext ctx(opts);
|
||||
SwiftDeclCollector collector(ctx);
|
||||
llvm::SmallVector<ModuleDecl*, 4> modules;
|
||||
if (!Empty) {
|
||||
modules.push_back(MD);
|
||||
}
|
||||
SwiftDeclCollector collector(ctx, modules);
|
||||
ConstExtractor extractor(ctx, MD->getASTContext());
|
||||
PayLoad payload;
|
||||
SWIFT_DEFER {
|
||||
@@ -2613,7 +2628,6 @@ void swift::ide::api::dumpModuleContent(ModuleDecl *MD, llvm::raw_ostream &os,
|
||||
if (Empty) {
|
||||
return;
|
||||
}
|
||||
collector.lookupVisibleDecls({MD});
|
||||
extractor.extract(MD);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,6 @@
|
||||
// RUN: %FileCheck %s < %t/Foo-c.json
|
||||
|
||||
// CHECK: "kind": "Root"
|
||||
// CHECK-NEXT: "name": "TopLevel"
|
||||
// CHECK-NEXT: "printedName": "TopLevel"
|
||||
// CHECK-NEXT: "name":
|
||||
// CHECK-NEXT: "printedName":
|
||||
// CHECK: "kind": "Function"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"ABIRoot": {
|
||||
"kind": "Root",
|
||||
"name": "TopLevel",
|
||||
"printedName": "TopLevel",
|
||||
"name": "cake",
|
||||
"printedName": "cake",
|
||||
"children": [
|
||||
{
|
||||
"kind": "Import",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"ABIRoot": {
|
||||
"kind": "Root",
|
||||
"name": "TopLevel",
|
||||
"printedName": "TopLevel",
|
||||
"name": "cake",
|
||||
"printedName": "cake",
|
||||
"children": [
|
||||
{
|
||||
"kind": "Import",
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"ABIRoot": {
|
||||
"kind": "Root",
|
||||
"name": "TopLevel",
|
||||
"printedName": "TopLevel",
|
||||
"name": "NO_MODULE",
|
||||
"printedName": "NO_MODULE",
|
||||
"json_format_version": 8
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user