[all-commits] [llvm/llvm-project] b68261: Clang `unused-but-set-variable` warnings should no...

Michael Wyman via All-commits all-commits at lists.llvm.org
Thu Feb 24 14:26:37 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b682616d1fd1263b303985b9f930c1760033af2c
      https://github.com/llvm/llvm-project/commit/b682616d1fd1263b303985b9f930c1760033af2c
  Author: Michael Wyman <michael at mwyman.com>
  Date:   2022-02-24 (Thu, 24 Feb 2022)

  Changed paths:
    M clang/lib/Sema/SemaDecl.cpp
    A clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m

  Log Message:
  -----------
  Clang `unused-but-set-variable` warnings should not apply to `__attribute__((objc_precise_lifetime))` Objective-C pointers

The `objc_precise_lifetime` attribute is applied to Objective-C pointers to ensure the optimizer does not prematurely release an object under Automatic Reference Counting (ARC). It is a common enough pattern to assign values to these variables but not reference them otherwise, and annotating them with `__unused` is not really correct as they are being used to ensure an object's lifetime.

Differential Revision: https://reviews.llvm.org/D120372




More information about the All-commits mailing list