mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
swift-api-digester: teach the tool to serialize USRs for nominal type. (#15463)
This allows us to map back from a type to the declaration in the dump, so that we can perform more fine-grained analysis like whether a string has been changed to string enum.
This commit is contained in:
@@ -511,9 +511,12 @@ bool SDKNodeType::classof(const SDKNode *N) {
|
||||
}
|
||||
|
||||
class SDKNodeTypeNominal : public SDKNodeType {
|
||||
StringRef USR;
|
||||
public:
|
||||
SDKNodeTypeNominal(SDKNodeInitInfo Info) : SDKNodeType(Info,
|
||||
SDKNodeKind::TypeNominal) {}
|
||||
SDKNodeKind::TypeNominal), USR(Info.USR) {}
|
||||
// Get the usr of the correspoding nominal type decl.
|
||||
StringRef getUsr() const { return USR; }
|
||||
static bool classof(const SDKNode *N);
|
||||
};
|
||||
|
||||
@@ -1286,6 +1289,10 @@ SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, Type Ty,
|
||||
TypeInfo(TypeInfo) {
|
||||
if (isFunctionTypeNoEscape(Ty))
|
||||
TypeAttrs.push_back(TypeAttrKind::TAK_noescape);
|
||||
// If this is a nominal type, get its Usr.
|
||||
if (auto *ND = Ty->getAnyNominal()) {
|
||||
USR = calculateUsr(Ctx, ND);
|
||||
}
|
||||
}
|
||||
|
||||
SDKNodeInitInfo::SDKNodeInitInfo(SDKContext &Ctx, ValueDecl *VD)
|
||||
@@ -1760,6 +1767,12 @@ namespace swift {
|
||||
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_hasDefaultArg).data(),
|
||||
HasDefault);
|
||||
}
|
||||
// Serialize nominal type's USR.
|
||||
if (auto NT = dyn_cast<SDKNodeTypeNominal>(value)) {
|
||||
auto Usr = NT->getUsr();
|
||||
if (!Usr.empty())
|
||||
out.mapRequired(getKeyContent(Ctx, KeyKind::KK_usr).data(), Usr);
|
||||
}
|
||||
}
|
||||
if (!value->isLeaf()) {
|
||||
ArrayRef<SDKNode *> Children = value->getChildren();
|
||||
@@ -3424,7 +3437,7 @@ static int compareSDKs(StringRef LeftPath, StringRef RightPath,
|
||||
|
||||
llvm::errs() << "Dumping diff to " << DiffPath << '\n';
|
||||
std::vector<OverloadedFuncInfo> Overloads;
|
||||
OverloadMemberFunctionEmitter::collectDiffItems(RightModule, Overloads);
|
||||
// OverloadMemberFunctionEmitter::collectDiffItems(RightModule, Overloads);
|
||||
|
||||
std::error_code EC;
|
||||
llvm::raw_fd_ostream Fs(DiffPath, EC, llvm::sys::fs::F_None);
|
||||
|
||||
Reference in New Issue
Block a user