@@ -115,6 +115,9 @@ AbortOnModuleLoadFailure("abort-on-module-fail",
115
115
static llvm::cl::opt<bool >
116
116
Verbose (" v" , llvm::cl::desc(" Verbose" ));
117
117
118
+ static llvm::cl::opt<bool >
119
+ PrintModule (" print-module" , llvm::cl::desc(" Print module names in diagnostics" ));
120
+
118
121
static llvm::cl::opt<ActionType>
119
122
Action (llvm::cl::desc(" Mode:" ), llvm::cl::init(ActionType::None),
120
123
llvm::cl::values(
@@ -2656,79 +2659,95 @@ class DiagnosisEmitter : public SDKNodeVisitor {
2656
2659
llvm::outs () << " */\n " ;
2657
2660
removeRedundantAndSort (Diags);
2658
2661
std::for_each (Diags.begin (), Diags.end (), [](T &Diag) {
2662
+ Diag.outputModule ();
2659
2663
Diag.output ();
2660
2664
});
2661
2665
}
2662
2666
};
2663
2667
2664
- struct RemovedDeclDiag {
2668
+ struct DiagBase {
2669
+ StringRef ModuleName;
2670
+ DiagBase (StringRef ModuleName): ModuleName(ModuleName) {}
2671
+ virtual ~DiagBase () = default ;
2672
+ void outputModule () const {
2673
+ if (options::PrintModule)
2674
+ llvm::outs () << ModuleName << " : " ;
2675
+ }
2676
+ virtual void output () const = 0;
2677
+ };
2678
+
2679
+ struct RemovedDeclDiag : public DiagBase {
2665
2680
DeclKind Kind;
2666
2681
StringRef Name;
2667
2682
bool IsDeprecated;
2668
- RemovedDeclDiag (DeclKind Kind, StringRef Name, bool IsDeprecated) :
2669
- Kind (Kind), Name(Name), IsDeprecated(IsDeprecated) {}
2683
+ RemovedDeclDiag (StringRef ModuleName, DeclKind Kind, StringRef Name,
2684
+ bool IsDeprecated): DiagBase(ModuleName), Kind(Kind),
2685
+ Name (Name), IsDeprecated(IsDeprecated) {}
2670
2686
bool operator <(RemovedDeclDiag Other) const ;
2671
- void output () const ;
2687
+ void output () const override ;
2672
2688
static void theme (raw_ostream &OS) { OS << " Removed Decls" ; };
2673
2689
};
2674
2690
2675
- struct MovedDeclDiag {
2691
+ struct MovedDeclDiag : public DiagBase {
2676
2692
DeclKind RemovedKind;
2677
2693
DeclKind AddedKind;
2678
2694
StringRef RemovedName;
2679
2695
StringRef AddedName;
2680
- MovedDeclDiag (DeclKind RemovedKind, DeclKind AddedKind,
2681
- StringRef RemovedName, StringRef AddedName) :
2682
- RemovedKind (RemovedKind ), AddedKind(AddedKind ), RemovedName(RemovedName ),
2683
- AddedName (AddedName) {}
2696
+ MovedDeclDiag (StringRef ModuleName, DeclKind RemovedKind, DeclKind AddedKind,
2697
+ StringRef RemovedName, StringRef AddedName):
2698
+ DiagBase (ModuleName ), RemovedKind(RemovedKind ), AddedKind(AddedKind ),
2699
+ RemovedName (RemovedName), AddedName(AddedName) {}
2684
2700
bool operator <(MovedDeclDiag other) const ;
2685
- void output () const ;
2701
+ void output () const override ;
2686
2702
static void theme (raw_ostream &OS) { OS << " Moved Decls" ; };
2687
2703
};
2688
2704
2689
- struct RenamedDeclDiag {
2705
+ struct RenamedDeclDiag : public DiagBase {
2690
2706
DeclKind KindBefore;
2691
2707
DeclKind KindAfter;
2692
2708
StringRef NameBefore;
2693
2709
StringRef NameAfter;
2694
- RenamedDeclDiag (DeclKind KindBefore, DeclKind KindAfter,
2695
- StringRef NameBefore, StringRef NameAfter) :
2710
+ RenamedDeclDiag (StringRef ModuleName, DeclKind KindBefore, DeclKind KindAfter,
2711
+ StringRef NameBefore, StringRef NameAfter):
2712
+ DiagBase (ModuleName),
2696
2713
KindBefore (KindBefore), KindAfter(KindAfter),
2697
2714
NameBefore (NameBefore), NameAfter(NameAfter) {}
2698
2715
bool operator <(RenamedDeclDiag Other) const ;
2699
- void output () const ;
2716
+ void output () const override ;
2700
2717
static void theme (raw_ostream &OS) { OS << " Renamed Decls" ; };
2701
2718
};
2702
2719
2703
- struct DeclAttrDiag {
2720
+ struct DeclAttrDiag : public DiagBase {
2704
2721
DeclKind Kind;
2705
2722
StringRef DeclName;
2706
2723
StringRef AttrBefore;
2707
2724
StringRef AttrAfter;
2708
- DeclAttrDiag (DeclKind Kind, StringRef DeclName, StringRef AttrBefore,
2709
- StringRef AttrAfter) : Kind(Kind), DeclName(DeclName),
2710
- AttrBefore (AttrBefore), AttrAfter(AttrAfter) {}
2711
- DeclAttrDiag (DeclKind Kind, StringRef DeclName, StringRef AttrAfter) :
2712
- DeclAttrDiag(Kind, DeclName, StringRef(), AttrAfter) {}
2725
+ DeclAttrDiag (StringRef ModuleName, DeclKind Kind, StringRef DeclName,
2726
+ StringRef AttrBefore, StringRef AttrAfter):
2727
+ DiagBase (ModuleName), Kind(Kind), DeclName(DeclName),
2728
+ AttrBefore (AttrBefore), AttrAfter(AttrAfter) {}
2729
+ DeclAttrDiag (StringRef ModuleName, DeclKind Kind, StringRef DeclName,
2730
+ StringRef AttrAfter): DeclAttrDiag(ModuleName, Kind, DeclName,
2731
+ StringRef (), AttrAfter) {}
2713
2732
2714
2733
bool operator <(DeclAttrDiag Other) const ;
2715
- void output () const ;
2734
+ void output () const override ;
2716
2735
static void theme (raw_ostream &OS) { OS << " Decl Attribute changes" ; };
2717
2736
};
2718
2737
2719
- struct DeclTypeChangeDiag {
2738
+ struct DeclTypeChangeDiag : public DiagBase {
2720
2739
DeclKind Kind;
2721
2740
StringRef DeclName;
2722
2741
StringRef TypeNameBefore;
2723
2742
StringRef TypeNameAfter;
2724
2743
StringRef Description;
2725
- DeclTypeChangeDiag (DeclKind Kind, StringRef DeclName,
2744
+ DeclTypeChangeDiag (StringRef ModuleName, DeclKind Kind, StringRef DeclName,
2726
2745
StringRef TypeNameBefore, StringRef TypeNameAfter,
2727
- StringRef Description) :
2746
+ StringRef Description): DiagBase(ModuleName),
2728
2747
Kind (Kind), DeclName(DeclName), TypeNameBefore(TypeNameBefore),
2729
2748
TypeNameAfter(TypeNameAfter), Description(Description) {}
2730
2749
bool operator <(DeclTypeChangeDiag Other) const ;
2731
- void output () const ;
2750
+ void output () const override ;
2732
2751
static void theme (raw_ostream &OS) { OS << " Type Changes" ; };
2733
2752
};
2734
2753
@@ -2877,7 +2896,8 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
2877
2896
return ;
2878
2897
if (auto *Added = findAddedDecl (Node)) {
2879
2898
if (Node->getDeclKind () != DeclKind::Constructor) {
2880
- MovedDecls.Diags .emplace_back (Node->getDeclKind (),
2899
+ MovedDecls.Diags .emplace_back (Node->getModuleName (),
2900
+ Node->getDeclKind (),
2881
2901
Added->getDeclKind (),
2882
2902
Node->getFullyQualifiedName (),
2883
2903
Added->getFullyQualifiedName ());
@@ -2900,32 +2920,37 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
2900
2920
}
2901
2921
if (FoundInSuperclass)
2902
2922
return ;
2903
- RemovedDecls.Diags .emplace_back (Node->getDeclKind (),
2923
+ RemovedDecls.Diags .emplace_back (Node->getModuleName (),
2924
+ Node->getDeclKind (),
2904
2925
Node->getFullyQualifiedName (),
2905
2926
Node->isDeprecated ());
2906
2927
return ;
2907
2928
}
2908
2929
case NodeAnnotation::Rename: {
2909
2930
auto *Count = UpdateMap.findUpdateCounterpart (Node)->getAs <SDKNodeDecl>();
2910
- RenamedDecls.Diags .emplace_back (Node->getDeclKind (), Count->getDeclKind (),
2931
+ RenamedDecls.Diags .emplace_back (Node->getModuleName (),
2932
+ Node->getDeclKind (), Count->getDeclKind (),
2911
2933
Node->getFullyQualifiedName (),
2912
2934
Count->getFullyQualifiedName ());
2913
2935
return ;
2914
2936
}
2915
2937
case NodeAnnotation::NowMutating: {
2916
- AttrChangedDecls.Diags .emplace_back (Node->getDeclKind (),
2938
+ AttrChangedDecls.Diags .emplace_back (Node->getModuleName (),
2939
+ Node->getDeclKind (),
2917
2940
Node->getFullyQualifiedName (),
2918
2941
Ctx.buffer (" mutating" ));
2919
2942
return ;
2920
2943
}
2921
2944
case NodeAnnotation::NowThrowing: {
2922
- AttrChangedDecls.Diags .emplace_back (Node->getDeclKind (),
2945
+ AttrChangedDecls.Diags .emplace_back (Node->getModuleName (),
2946
+ Node->getDeclKind (),
2923
2947
Node->getFullyQualifiedName (),
2924
2948
Ctx.buffer (" throwing" ));
2925
2949
return ;
2926
2950
}
2927
2951
case NodeAnnotation::StaticChange: {
2928
- AttrChangedDecls.Diags .emplace_back (Node->getDeclKind (),
2952
+ AttrChangedDecls.Diags .emplace_back (Node->getModuleName (),
2953
+ Node->getDeclKind (),
2929
2954
Node->getFullyQualifiedName (),
2930
2955
Ctx.buffer (Node->isStatic () ? " not static" : " static" ));
2931
2956
return ;
@@ -2942,7 +2967,8 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
2942
2967
llvm_unreachable (" Unhandled Ownership in switch." );
2943
2968
};
2944
2969
auto *Count = UpdateMap.findUpdateCounterpart (Node)->getAs <SDKNodeDecl>();
2945
- AttrChangedDecls.Diags .emplace_back (Node->getDeclKind (),
2970
+ AttrChangedDecls.Diags .emplace_back (Node->getModuleName (),
2971
+ Node->getDeclKind (),
2946
2972
Node->getFullyQualifiedName (),
2947
2973
getOwnershipDescription (Node->getOwnership ()),
2948
2974
getOwnershipDescription (Count->getOwnership ()));
@@ -2977,7 +3003,8 @@ void DiagnosisEmitter::visitType(SDKNodeType *Node) {
2977
3003
SDKNodeAbstractFunc::getTypeRoleDescription (Ctx, Parent->getChildIndex (Node)) :
2978
3004
Ctx.buffer (" declared" );
2979
3005
if (Node->getPrintedName () != Count->getPrintedName ())
2980
- TypeChangedDecls.Diags .emplace_back (Parent->getDeclKind (),
3006
+ TypeChangedDecls.Diags .emplace_back (Parent->getModuleName (),
3007
+ Parent->getDeclKind (),
2981
3008
Parent->getFullyQualifiedName (),
2982
3009
Node->getPrintedName (),
2983
3010
Count->getPrintedName (),
0 commit comments