[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute
Valeriy Savchenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 24 08:39:55 PST 2020
vsavchenko created this revision.
vsavchenko added reviewers: aaron.ballman, dexonsmith, rsmith, Bigcheese, rjmccall, NoQ, doug.gregor, ravikandhadai, dcoughlin.
Herald added subscribers: cfe-commits, Charusso, mgorny.
Herald added a project: clang.
vsavchenko requested review of this revision.
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`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D92039
Files:
clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Analysis/CMakeLists.txt
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaObjC/attr-called-once.m
clang/test/SemaObjC/warn-called-once.m
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92039.307375.patch
Type: text/x-patch
Size: 92147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201124/9fd1cfbb/attachment-0001.bin>
More information about the cfe-commits
mailing list