[PATCH] D113530: [wip] [analyzer] support use-after-free checking with parameter annotation
Chris D'Angelo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 22 13:55:18 PST 2021
chrisdangelo updated this revision to Diff 395926.
chrisdangelo added a comment.
"I think it makes sense to simply copy that file and replace function attributes with parameter attributes and see if it still passes." - @NoQ (Tue, Dec 21, 12:28 PM)
Sounds good. This newest change adds malloc-annotations-param.c and malloc-annotations-param.cpp.
This change begins work to use ownership_takes and ownership_holds parameter attributes for the same tests still using function attributes in malloc-annotations.c and malloc-annotations.cpp respectively.
Note that this is just the beginning of the work to test parameter based ownership attributes. There are many misuse scenarios that are currently not supported in these changes, and not tested.
I've explained a bit more below, and plan to explain a bit more on the comment coinciding with the next Differential attachment.
"Do we also need to convert ownership_holds to parameter attribute? I think it doesn't make sense to deprecate until we convert all of them." - @NoQ (Tue, Dec 21, 12:28 PM)
ownership_holds is expected to be functioning. However, there are several misuse scenarios that I've not yet accounted for.
Example 1: What happens if the developer uses the function attribute and parameter attribute on the same parameter with different ownership types?
Example 2: What happens if the developer uses multiple parameter attributes of varying owernship types on the same parameter?
Additionally, ownership_returns compile-time or analysis-time validation is not completely or correctly supported today. For example, nothing prevents the developer from attempting to apply ownership_returns to a parameter in a function.
-
These changes have been tested by successfully running `ninja check-clang-analysis`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113530/new/
https://reviews.llvm.org/D113530
Files:
clang/include/clang/Basic/Attr.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/test/Analysis/malloc-annotations-param.c
clang/test/Analysis/malloc-annotations-param.cpp
clang/test/Analysis/malloc-annotations.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113530.395926.patch
Type: text/x-patch
Size: 24623 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211222/6391b66a/attachment-0001.bin>
More information about the cfe-commits
mailing list