@@ -678,11 +678,9 @@ void swift::ide::api::SDKNodeDeclType::diagnose(SDKNode *Right) {
678
678
auto *R = dyn_cast<SDKNodeDeclType>(Right);
679
679
if (!R)
680
680
return ;
681
- auto &Diags = Ctx.getDiags ();
682
681
683
682
if (getDeclKind () != R->getDeclKind ()) {
684
- Diags.diagnose (SourceLoc (), diag::decl_kind_changed, getScreenInfo (),
685
- getDeclKindStr (R->getDeclKind ()));
683
+ emitDiag (diag::decl_kind_changed, getDeclKindStr (R->getDeclKind ()));
686
684
return ;
687
685
}
688
686
@@ -694,11 +692,9 @@ void swift::ide::api::SDKNodeDeclType::diagnose(SDKNode *Right) {
694
692
auto RSuperClass = R->getSuperClassName ();
695
693
if (!LSuperClass.empty () && LSuperClass != RSuperClass) {
696
694
if (RSuperClass.empty ()) {
697
- Diags.diagnose (SourceLoc (), diag::super_class_removed, getScreenInfo (),
698
- LSuperClass);
695
+ emitDiag (diag::super_class_removed, LSuperClass);
699
696
} else if (!contains (R->getClassInheritanceChain (), LSuperClass)) {
700
- Diags.diagnose (SourceLoc (), diag::super_class_changed, getScreenInfo (),
701
- LSuperClass, RSuperClass);
697
+ emitDiag (diag::super_class_changed, LSuperClass, RSuperClass);
702
698
}
703
699
}
704
700
break ;
@@ -713,11 +709,9 @@ void swift::ide::api::SDKNodeDeclAbstractFunc::diagnose(SDKNode *Right) {
713
709
auto *R = dyn_cast<SDKNodeDeclAbstractFunc>(Right);
714
710
if (!R)
715
711
return ;
716
- auto &Diags = Ctx.getDiags ();
717
712
718
713
if (!isThrowing () && R->isThrowing ()) {
719
- Diags.diagnose (SourceLoc (), diag::decl_new_attr, getScreenInfo (),
720
- Ctx.buffer (" throwing" ));
714
+ emitDiag (diag::decl_new_attr, Ctx.buffer (" throwing" ));
721
715
}
722
716
}
723
717
@@ -726,15 +720,13 @@ void swift::ide::api::SDKNodeDeclFunction::diagnose(SDKNode *Right) {
726
720
auto *R = dyn_cast<SDKNodeDeclFunction>(Right);
727
721
if (!R)
728
722
return ;
729
- auto &Diags = Ctx.getDiags ();
730
723
if (getSelfAccessKind () != R->getSelfAccessKind ()) {
731
- Diags. diagnose ( SourceLoc (), diag::func_self_access_change, getScreenInfo (),
732
- getSelfAccessKind (), R->getSelfAccessKind ());
724
+ emitDiag ( diag::func_self_access_change, getSelfAccessKind (),
725
+ R->getSelfAccessKind ());
733
726
}
734
727
if (Ctx.checkingABI ()) {
735
728
if (hasFixedBinaryOrder () != R->hasFixedBinaryOrder ()) {
736
- Ctx.getDiags ().diagnose (SourceLoc (), diag::func_has_fixed_order_change,
737
- getScreenInfo (), hasFixedBinaryOrder ());
729
+ emitDiag (diag::func_has_fixed_order_change, hasFixedBinaryOrder ());
738
730
}
739
731
}
740
732
}
@@ -745,8 +737,7 @@ void swift::ide::api::SDKNodeDeclSubscript::diagnose(SDKNode *Right) {
745
737
if (!R)
746
738
return ;
747
739
if (hasSetter () && !R->hasSetter ()) {
748
- Ctx.getDiags ().diagnose (SourceLoc (), diag::removed_setter,
749
- getScreenInfo ());
740
+ emitDiag (diag::removed_setter);
750
741
}
751
742
}
752
743
@@ -755,16 +746,15 @@ void swift::ide::api::SDKNodeDecl::diagnose(SDKNode *Right) {
755
746
auto *RD = dyn_cast<SDKNodeDecl>(Right);
756
747
if (!RD)
757
748
return ;
758
- auto &Diags = Ctx.getDiags ();
759
749
detectRename (this , RD);
760
750
if (isOpen () && !RD->isOpen ()) {
761
- Diags. diagnose ( SourceLoc (), diag::no_longer_open, getScreenInfo () );
751
+ emitDiag ( diag::no_longer_open);
762
752
}
763
753
764
754
// Diagnose static attribute change.
765
755
if (isStatic () ^ RD->isStatic ()) {
766
- Diags. diagnose ( SourceLoc (), diag::decl_new_attr, getScreenInfo (),
767
- Ctx. buffer ( isStatic () ? " not static " : " static" ));
756
+ emitDiag ( diag::decl_new_attr, Ctx. buffer ( isStatic () ? " not static " :
757
+ " static" ));
768
758
}
769
759
770
760
// Diagnose ownership change.
@@ -775,24 +765,22 @@ void swift::ide::api::SDKNodeDecl::diagnose(SDKNode *Right) {
775
765
return Ctx.buffer (" strong" );
776
766
return keywordOf (O);
777
767
};
778
- Diags. diagnose ( SourceLoc (), diag::decl_attr_change, getScreenInfo () ,
779
- getOwnershipDescription (getReferenceOwnership ()),
780
- getOwnershipDescription (RD->getReferenceOwnership ()));
768
+ emitDiag ( diag::decl_attr_change,
769
+ getOwnershipDescription (getReferenceOwnership ()),
770
+ getOwnershipDescription (RD->getReferenceOwnership ()));
781
771
}
782
772
// Diagnose generic signature change
783
773
if (getGenericSignature () != RD->getGenericSignature ()) {
784
- Diags. diagnose ( SourceLoc (), diag::generic_sig_change, getScreenInfo () ,
785
- getGenericSignature (), RD->getGenericSignature ());
774
+ emitDiag ( diag::generic_sig_change,
775
+ getGenericSignature (), RD->getGenericSignature ());
786
776
}
787
777
if (isOptional () != RD->isOptional ()) {
788
778
if (Ctx.checkingABI ()) {
789
779
// Both adding/removing optional is ABI-breaking.
790
- Diags.diagnose (SourceLoc (), diag::optional_req_changed,
791
- getScreenInfo (), isOptional ());
780
+ emitDiag (diag::optional_req_changed, isOptional ());
792
781
} else if (isOptional ()) {
793
782
// Removing optional is source-breaking.
794
- Diags.diagnose (SourceLoc (), diag::optional_req_changed,
795
- getScreenInfo (), isOptional ());
783
+ emitDiag (diag::optional_req_changed, isOptional ());
796
784
}
797
785
}
798
786
@@ -802,18 +790,15 @@ void swift::ide::api::SDKNodeDecl::diagnose(SDKNode *Right) {
802
790
auto Desc = hasDeclAttribute (Info.Kind ) ?
803
791
Ctx.buffer ((llvm::Twine (" without " ) + Info.Content ).str ()):
804
792
Ctx.buffer ((llvm::Twine (" with " ) + Info.Content ).str ());
805
- Diags.diagnose (SourceLoc (), diag::decl_new_attr, getScreenInfo (),
806
- Desc);
793
+ emitDiag (diag::decl_new_attr, Desc);
807
794
}
808
795
}
809
796
810
797
if (Ctx.checkingABI ()) {
811
798
if (hasFixedBinaryOrder () && RD->hasFixedBinaryOrder () &&
812
799
getFixedBinaryOrder () != RD->getFixedBinaryOrder ()) {
813
- Ctx.getDiags ().diagnose (SourceLoc (), diag::decl_reorder,
814
- getScreenInfo (),
815
- getFixedBinaryOrder (),
816
- RD->getFixedBinaryOrder ());
800
+ emitDiag (diag::decl_reorder, getFixedBinaryOrder (),
801
+ RD->getFixedBinaryOrder ());
817
802
}
818
803
}
819
804
}
@@ -824,8 +809,7 @@ void swift::ide::api::SDKNodeDeclOperator::diagnose(SDKNode *Right) {
824
809
if (!RO)
825
810
return ;
826
811
if (getDeclKind () != RO->getDeclKind ()) {
827
- Ctx.getDiags ().diagnose (SourceLoc (), diag::decl_kind_changed, getScreenInfo (),
828
- getDeclKindStr (RO->getDeclKind ()));
812
+ emitDiag (diag::decl_kind_changed, getDeclKindStr (RO->getDeclKind ()));
829
813
}
830
814
}
831
815
@@ -835,18 +819,14 @@ void swift::ide::api::SDKNodeDeclVar::diagnose(SDKNode *Right) {
835
819
if (!RV)
836
820
return ;
837
821
if (getSetter () && !RV->getSetter ()) {
838
- Ctx.getDiags ().diagnose (SourceLoc (), diag::removed_setter,
839
- getScreenInfo ());
822
+ emitDiag (diag::removed_setter);
840
823
}
841
824
if (Ctx.checkingABI ()) {
842
825
if (hasFixedBinaryOrder () != RV->hasFixedBinaryOrder ()) {
843
- Ctx.getDiags ().diagnose (SourceLoc (), diag::var_has_fixed_order_change,
844
- getScreenInfo (), hasFixedBinaryOrder ());
826
+ emitDiag (diag::var_has_fixed_order_change, hasFixedBinaryOrder ());
845
827
}
846
828
if (isLet () != RV->isLet ()) {
847
- Ctx.getDiags ().diagnose (SourceLoc (), diag::var_let_changed,
848
- getScreenInfo (),
849
- isLet ());
829
+ emitDiag (diag::var_let_changed, isLet ());
850
830
}
851
831
}
852
832
}
@@ -857,7 +837,6 @@ static bool shouldDiagnoseType(SDKNodeType *T) {
857
837
858
838
void swift::ide::api::SDKNodeType::diagnose (SDKNode *Right) {
859
839
SDKNode::diagnose (Right);
860
- auto &Diags = Ctx.getDiags ();
861
840
auto *RT = dyn_cast<SDKNodeType>(Right);
862
841
if (!RT || !shouldDiagnoseType (this ))
863
842
return ;
@@ -867,10 +846,10 @@ void swift::ide::api::SDKNodeType::diagnose(SDKNode *Right) {
867
846
if (auto *Wit = dyn_cast<SDKNodeTypeWitness>(getParent ())) {
868
847
auto *Conform = Wit->getParent ()->getAs <SDKNodeConformance>();
869
848
if (Ctx.checkingABI () && getPrintedName () != RT->getPrintedName ()) {
870
- Diags. diagnose ( SourceLoc (), diag::type_witness_change,
871
- Conform-> getNominalTypeDecl ()-> getScreenInfo (),
872
- Wit-> getWitnessedTypeName (),
873
- getPrintedName (), RT->getPrintedName ());
849
+ Conform-> getNominalTypeDecl ()-> emitDiag ( diag::type_witness_change,
850
+ Wit-> getWitnessedTypeName (),
851
+ getPrintedName (),
852
+ RT->getPrintedName ());
874
853
}
875
854
return ;
876
855
}
@@ -881,35 +860,31 @@ void swift::ide::api::SDKNodeType::diagnose(SDKNode *Right) {
881
860
assert (LParent->getKind () == RT->getParent ()->getAs <SDKNodeDecl>()->getKind ());
882
861
883
862
if (getPrintedName () != RT->getPrintedName ()) {
884
- Diags. diagnose ( SourceLoc (), diag::decl_type_change, LParent-> getScreenInfo () ,
885
- Descriptor, getPrintedName (), RT->getPrintedName ());
863
+ LParent-> emitDiag ( diag::decl_type_change,
864
+ Descriptor, getPrintedName (), RT->getPrintedName ());
886
865
}
887
866
888
867
if (hasDefaultArgument () && !RT->hasDefaultArgument ()) {
889
- Diags.diagnose (SourceLoc (), diag::default_arg_removed,
890
- LParent->getScreenInfo (), Descriptor);
868
+ LParent->emitDiag (diag::default_arg_removed, Descriptor);
891
869
}
892
870
if (getParamValueOwnership () != RT->getParamValueOwnership ()) {
893
- Diags.diagnose (SourceLoc (), diag::param_ownership_change,
894
- getParent ()->getAs <SDKNodeDecl>()->getScreenInfo (),
895
- getTypeRoleDescription (),
896
- getParamValueOwnership (),
897
- RT->getParamValueOwnership ());
871
+ getParent ()->getAs <SDKNodeDecl>()->emitDiag (diag::param_ownership_change,
872
+ getTypeRoleDescription (),
873
+ getParamValueOwnership (),
874
+ RT->getParamValueOwnership ());
898
875
}
899
876
}
900
877
901
878
void swift::ide::api::SDKNodeTypeFunc::diagnose (SDKNode *Right) {
902
879
SDKNode::diagnose (Right);
903
- auto &Diags = Ctx.getDiags ();
904
880
auto *RT = dyn_cast<SDKNodeTypeFunc>(Right);
905
881
if (!RT || !shouldDiagnoseType (this ))
906
882
return ;
907
883
assert (isTopLevelType ());
908
884
if (Ctx.checkingABI () && isEscaping () != RT->isEscaping ()) {
909
- Diags.diagnose (SourceLoc (), diag::func_type_escaping_changed,
910
- getParent ()->getAs <SDKNodeDecl>()->getScreenInfo (),
911
- getTypeRoleDescription (),
912
- isEscaping ());
885
+ getParent ()->getAs <SDKNodeDecl>()->emitDiag (diag::func_type_escaping_changed,
886
+ getTypeRoleDescription (),
887
+ isEscaping ());
913
888
}
914
889
}
915
890
@@ -980,8 +955,7 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
980
955
// Any order-important decl added to a non-resilient type breaks ABI.
981
956
if (auto *D = dyn_cast<SDKNodeDecl>(Right)) {
982
957
if (D->hasFixedBinaryOrder ()) {
983
- Ctx.getDiags ().diagnose (SourceLoc (), diag::decl_added,
984
- D->getScreenInfo ());
958
+ D->emitDiag (diag::decl_added);
985
959
}
986
960
}
987
961
}
@@ -995,23 +969,21 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
995
969
ShouldComplain = false ;
996
970
}
997
971
if (ShouldComplain &&
998
- ProtocolReqWhitelist.count (D->getParent ()->getAs <SDKNodeDecl>()->getFullyQualifiedName ())) {
972
+ ProtocolReqWhitelist.count (D->getParent ()->getAs <SDKNodeDecl>()->
973
+ getFullyQualifiedName ())) {
999
974
// Ignore protocol requirement additions if the protocol has been added
1000
975
// to the whitelist.
1001
976
ShouldComplain = false ;
1002
977
}
1003
978
if (ShouldComplain)
1004
- Ctx.getDiags ().diagnose (SourceLoc (), diag::protocol_req_added,
1005
- D->getScreenInfo ());
979
+ D->emitDiag (diag::protocol_req_added);
1006
980
}
1007
981
}
1008
982
// Diagnose an inherited protocol has been added.
1009
983
if (auto *Conf = dyn_cast<SDKNodeConformance>(Right)) {
1010
984
auto *TD = Conf->getNominalTypeDecl ();
1011
985
if (TD->isProtocol ()) {
1012
- Ctx.getDiags ().diagnose (SourceLoc (), diag::conformance_added,
1013
- TD->getScreenInfo (),
1014
- Conf->getName ());
986
+ TD->emitDiag (diag::conformance_added, Conf->getName ());
1015
987
}
1016
988
}
1017
989
@@ -1021,17 +993,16 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
1021
993
Left->annotate (NodeAnnotation::Removed);
1022
994
if (auto *LT = dyn_cast<SDKNodeType>(Left)) {
1023
995
if (auto *AT = dyn_cast<SDKNodeDeclAssociatedType>(LT->getParent ())) {
1024
- Ctx.getDiags ().diagnose (SourceLoc (),
1025
- diag::default_associated_type_removed,
1026
- AT->getScreenInfo (), LT->getPrintedName ());
996
+ AT->emitDiag (diag::default_associated_type_removed,
997
+ LT->getPrintedName ());
1027
998
}
1028
999
}
1029
1000
// Diagnose a protocol conformance has been removed.
1030
1001
if (auto *Conf = dyn_cast<SDKNodeConformance>(Left)) {
1031
1002
auto *TD = Conf->getNominalTypeDecl ();
1032
- Ctx. getDiags (). diagnose ( SourceLoc (), diag::conformance_removed,
1033
- TD-> getScreenInfo (), Conf->getName (),
1034
- TD->isProtocol ());
1003
+ TD-> emitDiag ( diag::conformance_removed,
1004
+ Conf->getName (),
1005
+ TD->isProtocol ());
1035
1006
}
1036
1007
return ;
1037
1008
case NodeMatchReason::FuncToProperty:
@@ -1807,11 +1778,10 @@ class DiagnosisEmitter : public SDKNodeVisitor {
1807
1778
UpdatedNodesMap &UpdateMap;
1808
1779
NodeMap &TypeAliasUpdateMap;
1809
1780
TypeMemberDiffVector &MemberChanges;
1810
- DiagnosticEngine &Diags;
1811
1781
DiagnosisEmitter (SDKContext &Ctx):
1812
1782
UpdateMap (Ctx.getNodeUpdateMap()),
1813
1783
TypeAliasUpdateMap (Ctx.getTypeAliasUpdateMap()),
1814
- MemberChanges (Ctx.getTypeMemberDiffs()), Diags(Ctx.getDiags()) {}
1784
+ MemberChanges (Ctx.getTypeMemberDiffs()) {}
1815
1785
1816
1786
public:
1817
1787
static void diagnosis (NodePtr LeftRoot, NodePtr RightRoot,
@@ -1866,7 +1836,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
1866
1836
return ;
1867
1837
if (auto *Added = findAddedDecl (Node)) {
1868
1838
if (Node->getDeclKind () != DeclKind::Constructor) {
1869
- Diags. diagnose ( SourceLoc (), diag::moved_decl, Node-> getScreenInfo () ,
1839
+ Node-> emitDiag ( diag::moved_decl,
1870
1840
Ctx.buffer ((Twine (getDeclKindStr (Added->getDeclKind ())) + " " +
1871
1841
Added->getFullyQualifiedName ()).str ()));
1872
1842
return ;
@@ -1878,7 +1848,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
1878
1848
auto It = std::find_if (MemberChanges.begin (), MemberChanges.end (),
1879
1849
[&](TypeMemberDiffItem &Item) { return Item.usr == Node->getUsr (); });
1880
1850
if (It != MemberChanges.end ()) {
1881
- Diags. diagnose ( SourceLoc (), diag::renamed_decl, Node-> getScreenInfo () ,
1851
+ Node-> emitDiag ( diag::renamed_decl,
1882
1852
Ctx.buffer ((Twine (getDeclKindStr (Node->getDeclKind ())) + " " +
1883
1853
It->newTypeName + " ." + It->newPrintedName ).str ()));
1884
1854
return ;
@@ -1889,7 +1859,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
1889
1859
// refine diagnostics message instead of showing the type alias has been
1890
1860
// removed.
1891
1861
if (TypeAliasUpdateMap.find ((SDKNode*)Node) != TypeAliasUpdateMap.end ()) {
1892
- Diags. diagnose ( SourceLoc (), diag::raw_type_change, Node-> getScreenInfo () ,
1862
+ Node-> emitDiag ( diag::raw_type_change,
1893
1863
Node->getAs <SDKNodeDeclTypeAlias>()->getUnderlyingType ()->getPrintedName (),
1894
1864
TypeAliasUpdateMap[(SDKNode*)Node]->getAs <SDKNodeDeclType>()->
1895
1865
getRawValueType ()->getPrintedName ());
@@ -1911,13 +1881,12 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
1911
1881
}
1912
1882
if (FoundInSuperclass)
1913
1883
return ;
1914
- Diags.diagnose (SourceLoc (), diag::removed_decl, Node->getScreenInfo (),
1915
- Node->isDeprecated ());
1884
+ Node->emitDiag (diag::removed_decl, Node->isDeprecated ());
1916
1885
return ;
1917
1886
}
1918
1887
case NodeAnnotation::Rename: {
1919
1888
auto *Count = UpdateMap.findUpdateCounterpart (Node)->getAs <SDKNodeDecl>();
1920
- Diags. diagnose ( SourceLoc (), diag::renamed_decl, Node-> getScreenInfo () ,
1889
+ Node-> emitDiag ( diag::renamed_decl,
1921
1890
Ctx.buffer ((Twine (getDeclKindStr (Count->getDeclKind ())) + " " +
1922
1891
Count->getFullyQualifiedName ()).str ()));
1923
1892
return ;
0 commit comments