@@ -252,6 +252,7 @@ class SDKContext {
252
252
llvm::BumpPtrAllocator Allocator;
253
253
UpdatedNodesMap UpdateMap;
254
254
NodeMap TypeAliasUpdateMap;
255
+ NodeMap RevertTypeAliasUpdateMap;
255
256
TypeMemberDiffVector TypeMemberDiffs;
256
257
public:
257
258
llvm::BumpPtrAllocator &allocator () {
@@ -266,6 +267,9 @@ class SDKContext {
266
267
NodeMap &getTypeAliasUpdateMap () {
267
268
return TypeAliasUpdateMap;
268
269
}
270
+ NodeMap &getRevertTypeAliasUpdateMap () {
271
+ return RevertTypeAliasUpdateMap;
272
+ }
269
273
TypeMemberDiffVector &getTypeMemberDiffs () {
270
274
return TypeMemberDiffs;
271
275
}
@@ -3793,6 +3797,27 @@ static int diagnoseModuleChange(StringRef LeftPath, StringRef RightPath) {
3793
3797
return 0 ;
3794
3798
}
3795
3799
3800
+ static void populateAliasChanges (NodeMap &AliasMap, DiffVector &AllItems,
3801
+ const bool isRevert) {
3802
+ for (auto Pair: AliasMap) {
3803
+ auto UnderlyingType = Pair.first ->getAs <SDKNodeDeclTypeAlias>()->
3804
+ getUnderlyingType ()->getPrintedName ();
3805
+ auto RawType = AliasMap[(SDKNode*)Pair.first ]->getAs <SDKNodeDeclType>()->
3806
+ getRawValueType ()->getPrintedName ();
3807
+ if (isRevert) {
3808
+ auto *D = Pair.second ->getAs <SDKNodeDecl>();
3809
+ AllItems.emplace_back (SDKNodeKind::DeclType,
3810
+ NodeAnnotation::RevertTypeAliasDeclToRawRepresentable, " 0" ,
3811
+ D->getUsr (), " " , RawType, UnderlyingType, D->getModuleName ());
3812
+ } else {
3813
+ auto *D = Pair.first ->getAs <SDKNodeDecl>();
3814
+ AllItems.emplace_back (SDKNodeKind::DeclTypeAlias,
3815
+ NodeAnnotation::TypeAliasDeclToRawRepresentable, " 0" ,
3816
+ D->getUsr (), " " , UnderlyingType, RawType, D->getModuleName ());
3817
+ }
3818
+ }
3819
+ }
3820
+
3796
3821
static int compareSDKs (StringRef LeftPath, StringRef RightPath,
3797
3822
StringRef DiffPath,
3798
3823
llvm::StringSet<> &IgnoredRemoveUsrs) {
@@ -3827,20 +3852,15 @@ static int compareSDKs(StringRef LeftPath, StringRef RightPath,
3827
3852
DiffVector AllItems;
3828
3853
DiffItemEmitter::collectDiffItems (LeftModule, AllItems);
3829
3854
3830
- auto &AliasMap = Ctx.getTypeAliasUpdateMap ();
3831
3855
// Find type alias change first.
3856
+ auto &AliasMap = Ctx.getTypeAliasUpdateMap ();
3832
3857
TypeAliasDiffFinder (LeftModule, RightModule, AliasMap).search ();
3858
+ populateAliasChanges (AliasMap, AllItems, /* IsRevert*/ false );
3833
3859
3834
- for (auto Pair: AliasMap) {
3835
- auto Left = Pair.first ->getAs <SDKNodeDeclTypeAlias>()->getUnderlyingType ()->
3836
- getPrintedName ();
3837
- auto Right = AliasMap[(SDKNode*)Pair.first ]->getAs <SDKNodeDeclType>()->
3838
- getRawValueType ()->getPrintedName ();
3839
- auto *D = Pair.first ->getAs <SDKNodeDecl>();
3840
- AllItems.emplace_back (SDKNodeKind::DeclTypeAlias,
3841
- NodeAnnotation::TypeAliasDeclToRawRepresentable, " 0" ,
3842
- D->getUsr (), " " , Left, Right, D->getModuleName ());
3843
- }
3860
+ // Find type alias revert change.
3861
+ auto &RevertAliasMap = Ctx.getRevertTypeAliasUpdateMap ();
3862
+ TypeAliasDiffFinder (RightModule, LeftModule, RevertAliasMap).search ();
3863
+ populateAliasChanges (RevertAliasMap, AllItems, /* IsRevert*/ true );
3844
3864
3845
3865
AllItems.erase (std::remove_if (AllItems.begin (), AllItems.end (),
3846
3866
[&](CommonDiffItem &Item) {
0 commit comments