@@ -383,6 +383,7 @@ class SDKNodeDecl : public SDKNode {
383
383
StringRef getUsr () const { return Usr; }
384
384
StringRef getLocation () const { return Location; }
385
385
StringRef getModuleName () const {return ModuleName;}
386
+ StringRef getHeaderName () const ;
386
387
void addDeclAttribute (SDKDeclAttrKind DAKind);
387
388
ArrayRef<SDKDeclAttrKind> getDeclAttributes () const ;
388
389
swift::Ownership getOwnership () const { return swift::Ownership (Ownership); }
@@ -396,6 +397,12 @@ class SDKNodeDecl : public SDKNode {
396
397
bool isStatic () const { return IsStatic; };
397
398
};
398
399
400
+ StringRef SDKNodeDecl::getHeaderName () const {
401
+ if (Location.empty ())
402
+ return StringRef ();
403
+ return llvm::sys::path::filename (Location.split (" :" ).first );
404
+ }
405
+
399
406
class SDKNodeRoot :public SDKNode {
400
407
// / This keeps track of all decl descendants with USRs.
401
408
llvm::StringMap<llvm::SmallSetVector<SDKNodeDecl*, 2 >> DescendantDeclTable;
@@ -1540,12 +1547,12 @@ namespace swift {
1540
1547
StringRef Usr = D->getUsr ();
1541
1548
StringRef Location = D->getLocation ();
1542
1549
StringRef ModuleName = D->getModuleName ();
1543
-
1544
1550
out.mapRequired (getKeyContent (Ctx, KeyKind::KK_declKind).data (), DK);
1545
1551
out.mapRequired (getKeyContent (Ctx, KeyKind::KK_usr).data (), Usr);
1546
1552
out.mapRequired (getKeyContent (Ctx, KeyKind::KK_location).data (), Location);
1547
1553
out.mapRequired (getKeyContent (Ctx, KeyKind::KK_moduleName).data (),
1548
1554
ModuleName);
1555
+
1549
1556
if (auto isStatic = D->isStatic ())
1550
1557
out.mapRequired (getKeyContent (Ctx, KeyKind::KK_static).data (), isStatic);
1551
1558
@@ -2665,13 +2672,24 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2665
2672
}
2666
2673
};
2667
2674
2668
- struct DiagBase {
2675
+ struct MetaInfo {
2669
2676
StringRef ModuleName;
2670
- DiagBase (StringRef ModuleName): ModuleName(ModuleName) {}
2677
+ StringRef HeaderName;
2678
+ MetaInfo (const SDKNodeDecl *Node):
2679
+ ModuleName (Node->getModuleName ()), HeaderName(Node->getHeaderName ()) {}
2680
+ };
2681
+
2682
+ struct DiagBase {
2683
+ MetaInfo Info;
2684
+ DiagBase (MetaInfo Info): Info(Info) {}
2671
2685
virtual ~DiagBase () = default ;
2672
2686
void outputModule () const {
2673
- if (options::PrintModule)
2674
- llvm::outs () << ModuleName << " : " ;
2687
+ if (options::PrintModule) {
2688
+ llvm::outs () << Info.ModuleName ;
2689
+ if (!Info.HeaderName .empty ())
2690
+ llvm::outs () << " (" << Info.HeaderName << " )" ;
2691
+ llvm::outs () << " : " ;
2692
+ }
2675
2693
}
2676
2694
virtual void output () const = 0;
2677
2695
};
@@ -2680,8 +2698,8 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2680
2698
DeclKind Kind;
2681
2699
StringRef Name;
2682
2700
bool IsDeprecated;
2683
- RemovedDeclDiag (StringRef ModuleName , DeclKind Kind, StringRef Name,
2684
- bool IsDeprecated): DiagBase(ModuleName ), Kind(Kind),
2701
+ RemovedDeclDiag (MetaInfo Info , DeclKind Kind, StringRef Name,
2702
+ bool IsDeprecated): DiagBase(Info ), Kind(Kind),
2685
2703
Name (Name), IsDeprecated(IsDeprecated) {}
2686
2704
bool operator <(RemovedDeclDiag Other) const ;
2687
2705
void output () const override ;
@@ -2693,9 +2711,9 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2693
2711
DeclKind AddedKind;
2694
2712
StringRef RemovedName;
2695
2713
StringRef AddedName;
2696
- MovedDeclDiag (StringRef ModuleName , DeclKind RemovedKind, DeclKind AddedKind,
2714
+ MovedDeclDiag (MetaInfo Info , DeclKind RemovedKind, DeclKind AddedKind,
2697
2715
StringRef RemovedName, StringRef AddedName):
2698
- DiagBase (ModuleName ), RemovedKind(RemovedKind), AddedKind(AddedKind),
2716
+ DiagBase (Info ), RemovedKind(RemovedKind), AddedKind(AddedKind),
2699
2717
RemovedName (RemovedName), AddedName(AddedName) {}
2700
2718
bool operator <(MovedDeclDiag other) const ;
2701
2719
void output () const override ;
@@ -2707,9 +2725,9 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2707
2725
DeclKind KindAfter;
2708
2726
StringRef NameBefore;
2709
2727
StringRef NameAfter;
2710
- RenamedDeclDiag (StringRef ModuleName , DeclKind KindBefore, DeclKind KindAfter,
2728
+ RenamedDeclDiag (MetaInfo Info , DeclKind KindBefore, DeclKind KindAfter,
2711
2729
StringRef NameBefore, StringRef NameAfter):
2712
- DiagBase (ModuleName ),
2730
+ DiagBase (Info ),
2713
2731
KindBefore (KindBefore), KindAfter(KindAfter),
2714
2732
NameBefore (NameBefore), NameAfter(NameAfter) {}
2715
2733
bool operator <(RenamedDeclDiag Other) const ;
@@ -2722,12 +2740,12 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2722
2740
StringRef DeclName;
2723
2741
StringRef AttrBefore;
2724
2742
StringRef AttrAfter;
2725
- DeclAttrDiag (StringRef ModuleName , DeclKind Kind, StringRef DeclName,
2743
+ DeclAttrDiag (MetaInfo Info , DeclKind Kind, StringRef DeclName,
2726
2744
StringRef AttrBefore, StringRef AttrAfter):
2727
- DiagBase (ModuleName ), Kind(Kind), DeclName(DeclName),
2745
+ DiagBase (Info ), Kind(Kind), DeclName(DeclName),
2728
2746
AttrBefore (AttrBefore), AttrAfter(AttrAfter) {}
2729
- DeclAttrDiag (StringRef ModuleName , DeclKind Kind, StringRef DeclName,
2730
- StringRef AttrAfter): DeclAttrDiag(ModuleName , Kind, DeclName,
2747
+ DeclAttrDiag (MetaInfo Info , DeclKind Kind, StringRef DeclName,
2748
+ StringRef AttrAfter): DeclAttrDiag(Info , Kind, DeclName,
2731
2749
StringRef (), AttrAfter) {}
2732
2750
2733
2751
bool operator <(DeclAttrDiag Other) const ;
@@ -2741,9 +2759,9 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2741
2759
StringRef TypeNameBefore;
2742
2760
StringRef TypeNameAfter;
2743
2761
StringRef Description;
2744
- DeclTypeChangeDiag (StringRef ModuleName , DeclKind Kind, StringRef DeclName,
2762
+ DeclTypeChangeDiag (MetaInfo Info , DeclKind Kind, StringRef DeclName,
2745
2763
StringRef TypeNameBefore, StringRef TypeNameAfter,
2746
- StringRef Description): DiagBase(ModuleName ),
2764
+ StringRef Description): DiagBase(Info ),
2747
2765
Kind (Kind), DeclName(DeclName), TypeNameBefore(TypeNameBefore),
2748
2766
TypeNameAfter(TypeNameAfter), Description(Description) {}
2749
2767
bool operator <(DeclTypeChangeDiag Other) const ;
@@ -2888,6 +2906,7 @@ void DiagnosisEmitter::diagnosis(NodePtr LeftRoot, NodePtr RightRoot,
2888
2906
void DiagnosisEmitter::handle (const SDKNodeDecl *Node, NodeAnnotation Anno) {
2889
2907
assert (Node->isAnnotatedAs (Anno));
2890
2908
auto &Ctx = Node->getSDKContext ();
2909
+ MetaInfo ScreenInfo (Node);
2891
2910
switch (Anno) {
2892
2911
case NodeAnnotation::Removed: {
2893
2912
// If we can find a type alias decl with the same name of this type, we
@@ -2896,7 +2915,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
2896
2915
return ;
2897
2916
if (auto *Added = findAddedDecl (Node)) {
2898
2917
if (Node->getDeclKind () != DeclKind::Constructor) {
2899
- MovedDecls.Diags .emplace_back (Node-> getModuleName () ,
2918
+ MovedDecls.Diags .emplace_back (ScreenInfo ,
2900
2919
Node->getDeclKind (),
2901
2920
Added->getDeclKind (),
2902
2921
Node->getFullyQualifiedName (),
@@ -2920,36 +2939,36 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
2920
2939
}
2921
2940
if (FoundInSuperclass)
2922
2941
return ;
2923
- RemovedDecls.Diags .emplace_back (Node-> getModuleName () ,
2942
+ RemovedDecls.Diags .emplace_back (ScreenInfo ,
2924
2943
Node->getDeclKind (),
2925
2944
Node->getFullyQualifiedName (),
2926
2945
Node->isDeprecated ());
2927
2946
return ;
2928
2947
}
2929
2948
case NodeAnnotation::Rename: {
2930
2949
auto *Count = UpdateMap.findUpdateCounterpart (Node)->getAs <SDKNodeDecl>();
2931
- RenamedDecls.Diags .emplace_back (Node-> getModuleName () ,
2950
+ RenamedDecls.Diags .emplace_back (ScreenInfo ,
2932
2951
Node->getDeclKind (), Count->getDeclKind (),
2933
2952
Node->getFullyQualifiedName (),
2934
2953
Count->getFullyQualifiedName ());
2935
2954
return ;
2936
2955
}
2937
2956
case NodeAnnotation::NowMutating: {
2938
- AttrChangedDecls.Diags .emplace_back (Node-> getModuleName () ,
2957
+ AttrChangedDecls.Diags .emplace_back (ScreenInfo ,
2939
2958
Node->getDeclKind (),
2940
2959
Node->getFullyQualifiedName (),
2941
2960
Ctx.buffer (" mutating" ));
2942
2961
return ;
2943
2962
}
2944
2963
case NodeAnnotation::NowThrowing: {
2945
- AttrChangedDecls.Diags .emplace_back (Node-> getModuleName () ,
2964
+ AttrChangedDecls.Diags .emplace_back (ScreenInfo ,
2946
2965
Node->getDeclKind (),
2947
2966
Node->getFullyQualifiedName (),
2948
2967
Ctx.buffer (" throwing" ));
2949
2968
return ;
2950
2969
}
2951
2970
case NodeAnnotation::StaticChange: {
2952
- AttrChangedDecls.Diags .emplace_back (Node-> getModuleName () ,
2971
+ AttrChangedDecls.Diags .emplace_back (ScreenInfo ,
2953
2972
Node->getDeclKind (),
2954
2973
Node->getFullyQualifiedName (),
2955
2974
Ctx.buffer (Node->isStatic () ? " not static" : " static" ));
@@ -2967,7 +2986,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
2967
2986
llvm_unreachable (" Unhandled Ownership in switch." );
2968
2987
};
2969
2988
auto *Count = UpdateMap.findUpdateCounterpart (Node)->getAs <SDKNodeDecl>();
2970
- AttrChangedDecls.Diags .emplace_back (Node-> getModuleName () ,
2989
+ AttrChangedDecls.Diags .emplace_back (ScreenInfo ,
2971
2990
Node->getDeclKind (),
2972
2991
Node->getFullyQualifiedName (),
2973
2992
getOwnershipDescription (Node->getOwnership ()),
@@ -2991,6 +3010,7 @@ void DiagnosisEmitter::visitType(SDKNodeType *Node) {
2991
3010
auto *Parent = dyn_cast<SDKNodeDecl>(Node->getParent ());
2992
3011
if (!Parent || Parent->isSDKPrivate ())
2993
3012
return ;
3013
+ MetaInfo ScreenInfo (Parent);
2994
3014
SDKContext &Ctx = Node->getSDKContext ();
2995
3015
if (Node->isAnnotatedAs (NodeAnnotation::Updated)) {
2996
3016
auto *Count = UpdateMap.findUpdateCounterpart (Node)->getAs <SDKNodeType>();
@@ -3003,7 +3023,7 @@ void DiagnosisEmitter::visitType(SDKNodeType *Node) {
3003
3023
SDKNodeAbstractFunc::getTypeRoleDescription (Ctx, Parent->getChildIndex (Node)) :
3004
3024
Ctx.buffer (" declared" );
3005
3025
if (Node->getPrintedName () != Count->getPrintedName ())
3006
- TypeChangedDecls.Diags .emplace_back (Parent-> getModuleName () ,
3026
+ TypeChangedDecls.Diags .emplace_back (ScreenInfo ,
3007
3027
Parent->getDeclKind (),
3008
3028
Parent->getFullyQualifiedName (),
3009
3029
Node->getPrintedName (),
0 commit comments