[llvm-branch-commits] [clang] [LifetimeSafety] Improve diagnostic messages to include variable names (PR #203577)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 12 09:28:33 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- clang/lib/Sema/SemaLifetimeSafety.h clang/test/Sema/LifetimeSafety/invalidations.cpp clang/test/Sema/LifetimeSafety/safety.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Sema/SemaLifetimeSafety.h b/clang/lib/Sema/SemaLifetimeSafety.h
index 554cbff9d..36ad0a8a3 100644
--- a/clang/lib/Sema/SemaLifetimeSafety.h
+++ b/clang/lib/Sema/SemaLifetimeSafety.h
@@ -202,8 +202,7 @@ public:
     S.Diag(PVD->getSourceRange().getBegin(),
            diag::warn_lifetime_safety_invalidated_field)
         << getDiagSubjectDescription(PVD)
-        << getDiagSubjectDescription(DanglingField)
-        << PVD->getSourceRange();
+        << getDiagSubjectDescription(DanglingField) << PVD->getSourceRange();
     S.Diag(InvalidationExpr->getExprLoc(), InvalidationDiag)
         << InvalidationExpr->getSourceRange();
     S.Diag(DanglingField->getLocation(),
@@ -243,8 +242,7 @@ public:
     S.Diag(PVD->getSourceRange().getBegin(),
            diag::warn_lifetime_safety_invalidated_global)
         << getDiagSubjectDescription(PVD)
-        << getDiagSubjectDescription(DanglingGlobal)
-        << PVD->getSourceRange();
+        << getDiagSubjectDescription(DanglingGlobal) << PVD->getSourceRange();
     S.Diag(InvalidationExpr->getExprLoc(), InvalidationDiag)
         << InvalidationExpr->getSourceRange();
     if (DanglingGlobal->isStaticLocal() || DanglingGlobal->isStaticDataMember())

``````````

</details>


https://github.com/llvm/llvm-project/pull/203577


More information about the llvm-branch-commits mailing list