[PATCH] D51901: Thread Safety Analysis: warnings for attributes without arguments
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 10 17:39:48 PDT 2018
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley, jmgao.
Herald added a subscriber: cfe-commits.
When thread safety annotations are used without capability arguments,
they are assumed to apply to `this` instead. So we warn when either
`this` doesn't exist, or the class is not a capability type.
This is based on earlier work by Josh Gao that was committed in r310403,
but reverted in r310698 because it didn't properly work in template
classes. See also https://reviews.llvm.org/D36237.
The solution is not to go via the QualType of `this`, which is then a
template type, hence the attributes are not known because it could be
specialized. Instead we look directly at the class in which we are
contained.
Additionally I grouped two of the warnings together. There are two
issues here: the existence of `this`, which requires us to be a
non-static member function, and the appropriate annotation on the class
we are contained in. So we don't distinguish between not being in a
class and being static, because in both cases we don't have `this`.
Fixes PR38399.
Repository:
rC Clang
https://reviews.llvm.org/D51901
Files:
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-capabilities.c
test/SemaCXX/warn-thread-safety-parsing.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51901.164778.patch
Type: text/x-patch
Size: 14951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180911/dd567e92/attachment-0001.bin>
More information about the cfe-commits
mailing list