From a6e96dcb93bb3353fe8170ad94ca94bdf5ccf1ce Mon Sep 17 00:00:00 2001 From: Andrea Gussoni Date: Tue, 30 Apr 2024 15:40:58 +0200 Subject: [PATCH] FallThroughScope: remove `SwitchBreak` type A `SwitchBreak` node should not have a specific associated `FallThroughScopeType`, since its semantics represent the fact of a `case` of the `switch` with no associated statements, and thus can be represented with the `FallThrough` behavior. --- lib/RestructureCFG/FallThroughScopeAnalysis.cpp | 5 ++++- lib/RestructureCFG/FallThroughScopeAnalysis.h | 1 - lib/RestructureCFG/PromoteCallNoReturn.cpp | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/RestructureCFG/FallThroughScopeAnalysis.cpp b/lib/RestructureCFG/FallThroughScopeAnalysis.cpp index 54e1b215a..dea17210d 100644 --- a/lib/RestructureCFG/FallThroughScopeAnalysis.cpp +++ b/lib/RestructureCFG/FallThroughScopeAnalysis.cpp @@ -227,7 +227,10 @@ fallThroughScopeImpl(const model::Binary &Model, rc_return FallThroughScopeType::FallThrough; } break; case ASTNode::NK_SwitchBreak: { - rc_return FallThroughScopeType::SwitchBreak; + + // `The `SwitchBreak` represents the fact that we fallthrough from the + // switch out + rc_return FallThroughScopeType::FallThrough; } break; case ASTNode::NK_Continue: { rc_return FallThroughScopeType::Continue; diff --git a/lib/RestructureCFG/FallThroughScopeAnalysis.h b/lib/RestructureCFG/FallThroughScopeAnalysis.h index d36d4f26b..b9a1b19bb 100644 --- a/lib/RestructureCFG/FallThroughScopeAnalysis.h +++ b/lib/RestructureCFG/FallThroughScopeAnalysis.h @@ -21,7 +21,6 @@ enum class FallThroughScopeType { Return, Continue, LoopBreak, - SwitchBreak, }; using FallThroughScopeTypeMap = std::map; diff --git a/lib/RestructureCFG/PromoteCallNoReturn.cpp b/lib/RestructureCFG/PromoteCallNoReturn.cpp index 7ff37abe7..879d033ed 100644 --- a/lib/RestructureCFG/PromoteCallNoReturn.cpp +++ b/lib/RestructureCFG/PromoteCallNoReturn.cpp @@ -30,8 +30,7 @@ static bool isPreferredAsFallThrough(FallThroughScopeType Element) { switch (Element) { case FallThroughScopeType::Return: case FallThroughScopeType::Continue: - case FallThroughScopeType::LoopBreak: - case FallThroughScopeType::SwitchBreak: { + case FallThroughScopeType::LoopBreak: { return true; } break; case FallThroughScopeType::FallThrough: