[all-commits] [llvm/llvm-project] fec1a4: [-Wcalled-once-parameter] Introduce 'called_once' ...

Valeriy Savchenko via All-commits all-commits at lists.llvm.org
Tue Jan 5 07:33:25 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: fec1a442e3b12fc01929b2b405d1abf7df9ab68e
      https://github.com/llvm/llvm-project/commit/fec1a442e3b12fc01929b2b405d1abf7df9ab68e
  Author: Valeriy Savchenko <vsavchenko at apple.com>
  Date:   2021-01-05 (Tue, 05 Jan 2021)

  Changed paths:
    M clang/include/clang/AST/ParentMap.h
    A clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/Analysis/CMakeLists.txt
    A clang/lib/Analysis/CalledOnceCheck.cpp
    M clang/lib/Sema/AnalysisBasedWarnings.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/test/Misc/pragma-attribute-supported-attributes-list.test
    A clang/test/SemaObjC/attr-called-once.m
    A clang/test/SemaObjC/warn-called-once.m

  Log Message:
  -----------
  [-Wcalled-once-parameter] Introduce 'called_once' attribute

This commit introduces a new attribute `called_once`.
It can be applied to function-like parameters to signify that
this parameter should be called exactly once.  This concept
is particularly widespread in asynchronous programs.

Additionally, this commit introduce a new group of dataflow
analysis-based warnings to check this property.  It identifies
and reports the following situations:
  * parameter is called twice
  * parameter is never called
  * parameter is not called on one of the paths

Current implementation can also automatically infer `called_once`
attribute for completion handler paramaters that should follow the
same principle by convention.  This behavior is OFF by default and
can be turned on by using `-Wcompletion-handler`.

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

rdar://72812043




More information about the All-commits mailing list