[PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 7 13:12:55 PST 2016


On Mon, Nov 7, 2016 at 11:44 AM, Alex Lorenz <arphaman at gmail.com> wrote:
> arphaman added a comment.
>
> I looked at the way `HasFallthroughStmt` is used, and it didn't seem so, no. It's used in the following manner in AnalysisBasedWarnings.cpp:
>
>   bool FallThroughDiagFull =
>       !Diags.isIgnored(diag::warn_unannotated_fallthrough, D->getLocStart());
>   bool FallThroughDiagPerFunction = !Diags.isIgnored(
>       diag::warn_unannotated_fallthrough_per_function, D->getLocStart());
>   if (FallThroughDiagFull || FallThroughDiagPerFunction ||
>       fscope->HasFallthroughStmt) {
>     DiagnoseSwitchLabelsFallthrough(S, AC, !FallThroughDiagFull);
>   }
>
> So it seems to me that even if `HasFallthroughStmt` isn't cleared, the analysis won't show up anything different for a function that re-used the scope info, because when diagnostics are ignored and the flag actually leads to incorrect call to `DiagnoseSwitchLabelsFallthrough `, the analysis won't show any warnings since the diagnostics are ignored. And likewise if one of the diagnostics is enabled then it doesn't matter if `HasFallthroughStmt` is true, so we won't be able to observe a difference there.

Thank you for looking into this! Drat on the lack of tests, but your
analysis makes sense to me.

~Aaron


More information about the cfe-commits mailing list