[all-commits] [llvm/llvm-project] 5c287e: [Clang] Extend lifetime bound analysis to support ...

Haojian Wu via All-commits all-commits at lists.llvm.org
Mon Jul 1 08:43:29 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5c287efee77930ab15fe5579bed00b2750bbb254
      https://github.com/llvm/llvm-project/commit/5c287efee77930ab15fe5579bed00b2750bbb254
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2024-07-01 (Mon, 01 Jul 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Sema/CheckExprLifetime.cpp
    M clang/lib/Sema/CheckExprLifetime.h
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/Parser/compound_literal.c
    M clang/test/SemaCXX/attr-lifetimebound.cpp
    M clang/test/SemaCXX/warn-dangling-local.cpp

  Log Message:
  -----------
  [Clang] Extend lifetime bound analysis to support assignments for the built-in pointer type (#96475)

The lifetime bound warning in Clang currently only considers
initializations. This patch extends the warning to include assignments.

- **Support for assignments of built-in pointer types**: this is done is
by reusing the existing statement-local implementation. Clang now warns
if the pointer is assigned to a temporary object that being destoryed at
the end of the full assignment expression.

With this patch, we will detect more cases under the on-by-default
diagnostic `-Wdangling`. I have added a new category for this specific
diagnostic so that people can temporarily disable it if their codebase
is not yet clean.

This is the first step to address #63310, focusing only on pointer
types. Support for C++ assignment operators will come in a follow-up
patch.

Fixes #54492



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list