diff options
author | JF Bastien <jfbastien@apple.com> | 2019-03-25 20:06:32 +0000 |
---|---|---|
committer | JF Bastien <jfbastien@apple.com> | 2019-03-25 20:06:32 +0000 |
commit | 96ad72202285f4473a4ae19c5d46e5a959ae24e5 (patch) | |
tree | 7dae2a6a5f034c90d9b2b33b3eb3d0aac15eebf8 /test/SemaObjCXX | |
parent | e05b36f6045598eed19bceb03e1fad6eeaa8abd0 (diff) | |
download | clang-96ad72202285f4473a4ae19c5d46e5a959ae24e5.tar.gz |
Thread Safety: also look at ObjC methods
Summary:
SExprBuilder::translateDeclRefExpr was only looking at FunctionDecl and not also looking at ObjCMethodDecl. It should consider both because the attributes can be used on Objective-C as well.
<rdar://problem/48941331>
Reviewers: dexonsmith, erik.pilkington
Subscribers: jkorous, jdoerfert, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D59523
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r-- | test/SemaObjCXX/no-crash-thread-safety-analysis.mm | 15 | ||||
-rw-r--r-- | test/SemaObjCXX/thread-safety-analysis.h | 17 | ||||
-rw-r--r-- | test/SemaObjCXX/warn-thread-safety-analysis.mm | 18 |
3 files changed, 33 insertions, 17 deletions
diff --git a/test/SemaObjCXX/no-crash-thread-safety-analysis.mm b/test/SemaObjCXX/no-crash-thread-safety-analysis.mm new file mode 100644 index 0000000000..6abd391dc2 --- /dev/null +++ b/test/SemaObjCXX/no-crash-thread-safety-analysis.mm @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -Wno-objc-root-class %s + +// Thread safety analysis used to crash when used with ObjC methods. + +#include "thread-safety-analysis.h" + +@interface MyInterface +- (void)doIt:(class Lock *)myLock; +@end + +@implementation MyInterface +- (void)doIt:(class Lock *)myLock { + AutoLock lock(*myLock); +} +@end diff --git a/test/SemaObjCXX/thread-safety-analysis.h b/test/SemaObjCXX/thread-safety-analysis.h new file mode 100644 index 0000000000..f657b7e50a --- /dev/null +++ b/test/SemaObjCXX/thread-safety-analysis.h @@ -0,0 +1,17 @@ +class __attribute__((lockable)) Lock { +public: + void Acquire() __attribute__((exclusive_lock_function())) {} + void Release() __attribute__((unlock_function())) {} +}; + +class __attribute__((scoped_lockable)) AutoLock { +public: + AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock))) + : lock_(lock) { + lock.Acquire(); + } + ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); } + +private: + Lock &lock_; +}; diff --git a/test/SemaObjCXX/warn-thread-safety-analysis.mm b/test/SemaObjCXX/warn-thread-safety-analysis.mm index 262ab7d108..a50c6f2ee1 100644 --- a/test/SemaObjCXX/warn-thread-safety-analysis.mm +++ b/test/SemaObjCXX/warn-thread-safety-analysis.mm @@ -1,22 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta -Wno-objc-root-class %s -class __attribute__((lockable)) Lock { -public: - void Acquire() __attribute__((exclusive_lock_function())) {} - void Release() __attribute__((unlock_function())) {} -}; - -class __attribute__((scoped_lockable)) AutoLock { -public: - AutoLock(Lock &lock) __attribute__((exclusive_lock_function(lock))) - : lock_(lock) { - lock.Acquire(); - } - ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); } - -private: - Lock &lock_; -}; +#include "thread-safety-analysis.h" @interface MyInterface { @private |