Skip to content

Commit 2ac57cf

Browse files
committed
swift-api-digester: add a flag to diagnostics indicating whether it's abi-specific.
1 parent 6dfff66 commit 2ac57cf

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3266,6 +3266,8 @@ class DiagnosisEmitter : public SDKNodeVisitor {
32663266
llvm::outs() << " */\n";
32673267
removeRedundantAndSort(Diags);
32683268
std::for_each(Diags.begin(), Diags.end(), [](T &Diag) {
3269+
if (Diag.isABISpecific() && !options::Abi)
3270+
return;
32693271
Diag.outputModule();
32703272
Diag.output();
32713273
});
@@ -3275,12 +3277,15 @@ class DiagnosisEmitter : public SDKNodeVisitor {
32753277
struct MetaInfo {
32763278
StringRef ModuleName;
32773279
StringRef HeaderName;
3278-
MetaInfo(const SDKNodeDecl *Node):
3279-
ModuleName(Node->getModuleName()), HeaderName(Node->getHeaderName()) {}
3280+
bool IsABISpecific;
3281+
MetaInfo(const SDKNodeDecl *Node, bool IsABISpecific = false):
3282+
ModuleName(Node->getModuleName()), HeaderName(Node->getHeaderName()),
3283+
IsABISpecific(IsABISpecific) {}
32803284
};
32813285

3282-
struct DiagBase {
3286+
class DiagBase {
32833287
MetaInfo Info;
3288+
public:
32843289
DiagBase(MetaInfo Info): Info(Info) {}
32853290
virtual ~DiagBase() = default;
32863291
void outputModule() const {
@@ -3292,6 +3297,7 @@ class DiagnosisEmitter : public SDKNodeVisitor {
32923297
}
32933298
}
32943299
virtual void output() const = 0;
3300+
bool isABISpecific() const { return Info.IsABISpecific; }
32953301
};
32963302

32973303
struct RemovedDeclDiag: public DiagBase {
@@ -3535,9 +3541,9 @@ void DiagnosisEmitter::diagnosis(NodePtr LeftRoot, NodePtr RightRoot,
35353541
void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
35363542
assert(Node->isAnnotatedAs(Anno));
35373543
auto &Ctx = Node->getSDKContext();
3538-
MetaInfo ScreenInfo(Node);
35393544
switch(Anno) {
35403545
case NodeAnnotation::Removed: {
3546+
MetaInfo ScreenInfo(Node, false);
35413547
// If we can find a type alias decl with the same name of this type, we
35423548
// consider the type is not removed.
35433549
if (findTypeAliasDecl(Node))
@@ -3599,6 +3605,7 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
35993605
return;
36003606
}
36013607
case NodeAnnotation::Rename: {
3608+
MetaInfo ScreenInfo(Node, false);
36023609
auto *Count = UpdateMap.findUpdateCounterpart(Node)->getAs<SDKNodeDecl>();
36033610
RenamedDecls.Diags.emplace_back(ScreenInfo,
36043611
Node->getDeclKind(), Count->getDeclKind(),
@@ -3607,27 +3614,31 @@ void DiagnosisEmitter::handle(const SDKNodeDecl *Node, NodeAnnotation Anno) {
36073614
return;
36083615
}
36093616
case NodeAnnotation::NowMutating: {
3617+
MetaInfo ScreenInfo(Node, false);
36103618
AttrChangedDecls.Diags.emplace_back(ScreenInfo,
36113619
Node->getDeclKind(),
36123620
Node->getFullyQualifiedName(),
36133621
Ctx.buffer("mutating"));
36143622
return;
36153623
}
36163624
case NodeAnnotation::NowThrowing: {
3625+
MetaInfo ScreenInfo(Node, false);
36173626
AttrChangedDecls.Diags.emplace_back(ScreenInfo,
36183627
Node->getDeclKind(),
36193628
Node->getFullyQualifiedName(),
36203629
Ctx.buffer("throwing"));
36213630
return;
36223631
}
36233632
case NodeAnnotation::StaticChange: {
3633+
MetaInfo ScreenInfo(Node, false);
36243634
AttrChangedDecls.Diags.emplace_back(ScreenInfo,
36253635
Node->getDeclKind(),
36263636
Node->getFullyQualifiedName(),
36273637
Ctx.buffer(Node->isStatic() ? "not static" : "static"));
36283638
return;
36293639
}
36303640
case NodeAnnotation::OwnershipChange: {
3641+
MetaInfo ScreenInfo(Node, false);
36313642
auto getOwnershipDescription = [&](swift::ReferenceOwnership O) {
36323643
if (O == ReferenceOwnership::Strong)
36333644
return Ctx.buffer("strong");
@@ -3692,7 +3703,7 @@ void DiagnosisEmitter::visit(NodePtr Node) {
36923703
}
36933704
}
36943705

3695-
typedef std::vector<NoEscapeFuncParam> NoEscapeFuncParamVector;
3706+
typedef std::vector<NoEscapeFuncParam> NoEscapeFuncParamVector;
36963707

36973708
class NoEscapingFuncEmitter : public SDKNodeVisitor {
36983709
NoEscapeFuncParamVector &AllItems;

0 commit comments

Comments
 (0)