mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
ABI checker: refactor the format of the ABI descriptor JSON to be more extensible. NFC
This commit is contained in:
@@ -628,6 +628,7 @@ SDKNode* SDKNode::constructSDKNode(SDKContext &Ctx,
|
||||
NodeVector Children;
|
||||
NodeVector Conformances;
|
||||
NodeVector Accessors;
|
||||
SDKNode *Result = nullptr;
|
||||
|
||||
for (auto &Pair : *Node) {
|
||||
auto keyString = GetScalarString(Pair.getKey());
|
||||
@@ -742,14 +743,18 @@ SDKNode* SDKNode::constructSDKNode(SDKContext &Ctx,
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (keyString == ABIRootKey) {
|
||||
Result = constructSDKNode(Ctx,
|
||||
cast<llvm::yaml::MappingNode>(Pair.getValue()));
|
||||
} else {
|
||||
Ctx.diagnose(Pair.getKey(), diag::sdk_node_unrecognized_key,
|
||||
keyString);
|
||||
Pair.skip();
|
||||
}
|
||||
};
|
||||
SDKNode *Result = Info.createSDKNode(Kind);
|
||||
if (Result)
|
||||
return Result;
|
||||
Result = Info.createSDKNode(Kind);
|
||||
for (auto C : Children) {
|
||||
Result->addChild(C);
|
||||
}
|
||||
@@ -2224,7 +2229,11 @@ void SwiftDeclCollector::serialize(StringRef Filename, SDKNode *Root) {
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream fs(Filename, EC, llvm::sys::fs::OF_None);
|
||||
json::Output yout(fs);
|
||||
yout << Root;
|
||||
assert(Root->getKind() == SDKNodeKind::Root);
|
||||
SDKNodeRoot &root = *static_cast<SDKNodeRoot*>(Root);
|
||||
yout.beginObject();
|
||||
yout.mapRequired(ABIRootKey, root);
|
||||
yout.endObject();
|
||||
}
|
||||
|
||||
// Serialize the content of all roots to a given file using JSON format.
|
||||
|
||||
Reference in New Issue
Block a user