[Bug 292067] [exp-run] Against llvm-21-update branch on GitHub

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 08 May 2026 18:16:22 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=292067

--- Comment #118 from commit-hook@FreeBSD.org ---
A commit in branch main references this bug:

URL:
https://cgit.FreeBSD.org/src/commit/?id=d9b272a19d39f71665b529860bfed731bcfd99f5

commit d9b272a19d39f71665b529860bfed731bcfd99f5
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-05-08 17:59:54 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-05-08 17:59:54 +0000

    Merge commit 871038759afb from llvm git (by Marco Elver):

      Thread Safety Analysis: Fix pointer handling of variables with deprecated
attributes (#148974)

      de10e44b6fe7 ("Thread Safety Analysis: Support warning on
      passing/returning pointers to guarded variables") added checks for
      passing pointer to guarded variables. While new features do not
      necessarily need to support the deprecated attributes (`guarded_var`,
      and `pt_guarded_var`), we need to ensure that such features do not cause
      the compiler to crash.

      As such, code such as this:

              struct {
                int v __attribute__((guarded_var));
              } p;

              int *g() {
                return &p.v;  // handleNoMutexHeld() with POK_ReturnPointer
              }

      Would crash in debug builds with the assertion in handleNoMutexHeld()
      triggering. The assertion is meant to capture the fact that this helper
      should only be used for warnings on variables (which the deprecated
      attributes only applied to).

      To fix, the function handleNoMutexHeld() should handle all POK cases
      that apply to variables explicitly, and produce a best-effort warning.

      We refrain from introducing new warnings to avoid unnecessary code bloat
      for deprecated features.

      Fixes: https://github.com/llvm/llvm-project/issues/140330

    This fixes an assertion while building the net/openvswitch port:
    "Assertion failed: ((POK == POK_VarAccess || POK == POK_VarDereference)
    && "Only works for variables"), function handleNoMutexHeld, file
    /usr/src/contrib/llvm-project/clang/lib/Sema/AnalysisBasedWarnings.cpp,
    line 2120.'

    Reported by:    cy
    PR:             295101, 292067
    MFC after:      1 month

 .../clang/lib/Sema/AnalysisBasedWarnings.cpp       | 25 +++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.