[clang][JumpDiagnostics] ignore non-asm goto target scopes
authorNick Desaulniers <ndesaulniers@google.com>
Fri, 21 Jul 2023 02:58:17 +0000 (19:58 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Fri, 21 Jul 2023 02:58:22 +0000 (19:58 -0700)
commitf023f5cdb2e6c19026f04a15b5a935c041835d14
treef266fb29570fc2532a39b3886aff35fdd0972caf
parentb8580ef717af1e85734d163f99d62c3b7c6711ad
[clang][JumpDiagnostics] ignore non-asm goto target scopes

The current behavior of JumpScopeChecker::VerifyIndirectOrAsmJumps was
to cross validate the scope of every jumping statement (goto, asm goto)
against the scope of every label (even if the label was not even a
possible target of the asm goto).

When we have multiple asm goto's with unique targets, we could trigger
false positive build errors complaining that labels that weren't even in
the asm goto's label list could not be jumped to.  Example:

    error: cannot jump from this asm goto statement to one of its possible targets
    asm goto(""::::foo);
    note: possible target of asm goto statement
    bar:
    ^

Fixes: https://github.com/ClangBuiltLinux/linux/issues/1886

Reviewed By: void, jyu2, rjmccall

Differential Revision: https://reviews.llvm.org/D155342
clang/docs/ReleaseNotes.rst
clang/lib/Sema/JumpDiagnostics.cpp
clang/test/Sema/asm-goto.cpp
clang/test/SemaCXX/goto2.cpp