swift-module-digester: diagnose let to var changes and vice versa as ABI breaking.

This commit is contained in:
Xi Ge
2018-09-27 14:25:35 -07:00
parent c5444a8e99
commit 0afafd1ca4
9 changed files with 31 additions and 10 deletions

View File

@@ -760,13 +760,19 @@ static void detectDeclChange(NodePtr L, NodePtr R, SDKContext &Ctx) {
// Detect re-ordering if they're from structs with a fixed layout.
auto *LV = dyn_cast<SDKNodeDeclVar>(L);
auto *RV = dyn_cast<SDKNodeDeclVar>(R);
if (LV && RV &&
LV->hasFixedBinaryOrder() && RV->hasFixedBinaryOrder() &&
LV->getFixedBinaryOrder() != RV->getFixedBinaryOrder()) {
Ctx.getDiags().diagnose(SourceLoc(), diag::decl_reorder,
LV->getScreenInfo(),
LV->getFixedBinaryOrder(),
RV->getFixedBinaryOrder());
if (LV && RV) {
if (LV->hasFixedBinaryOrder() && RV->hasFixedBinaryOrder() &&
LV->getFixedBinaryOrder() != RV->getFixedBinaryOrder()) {
Ctx.getDiags().diagnose(SourceLoc(), diag::decl_reorder,
LV->getScreenInfo(),
LV->getFixedBinaryOrder(),
RV->getFixedBinaryOrder());
}
if (LV->isLet() != RV->isLet()) {
Ctx.getDiags().diagnose(SourceLoc(), diag::var_let_changed,
LV->getScreenInfo(),
LV->isLet());
}
}
}