diff options
| author | Yi Kong <yikong@google.com> | 2017-12-14 22:24:45 +0000 |
|---|---|---|
| committer | Yi Kong <yikong@google.com> | 2017-12-14 22:24:45 +0000 |
| commit | 2d58d19c4854eb8051badacb1d2e6e5d6398426e (patch) | |
| tree | 6fc23324d6b3ca7dc152a8462729418f107e2495 /clang/test | |
| parent | 802de4f7ac0c495b14a4ba5eab47579ae4031b01 (diff) | |
| download | bcm5719-llvm-2d58d19c4854eb8051badacb1d2e6e5d6398426e.tar.gz bcm5719-llvm-2d58d19c4854eb8051badacb1d2e6e5d6398426e.zip | |
[ThreadSafetyAnalysis] Fix isCapabilityExpr
There are many more expr types that can be a capability expr, like
CXXThisExpr, CallExpr, MemberExpr. Instead of enumerating all of them,
just check typeHasCapability for any type given.
Also add & and * operators to allowed unary operators.
Differential Revision: https://reviews.llvm.org/D41224
llvm-svn: 320753
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Sema/attr-capabilities.cpp | 17 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-thread-safety-parsing.cpp | 3 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/test/Sema/attr-capabilities.cpp b/clang/test/Sema/attr-capabilities.cpp new file mode 100644 index 00000000000..5bae94edaa4 --- /dev/null +++ b/clang/test/Sema/attr-capabilities.cpp @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -fsyntax-only -Wthread-safety -verify %s + +class __attribute__((shared_capability("mutex"))) Mutex { + public: + void func1() __attribute__((assert_capability(this))); + void func2() __attribute__((assert_capability(!this))); + + const Mutex& operator!() const { return *this; } +}; + +class NotACapability { + public: + void func1() __attribute__((assert_capability(this))); // expected-warning {{'assert_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'NotACapability *'}} + void func2() __attribute__((assert_capability(!this))); // expected-warning {{'assert_capability' attribute requires arguments whose type is annotated with 'capability' attribute; type here is 'bool'}} + + const NotACapability& operator!() const { return *this; } +}; diff --git a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp index b66c027e52a..ac357e8dae3 100644 --- a/clang/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/clang/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -351,7 +351,8 @@ int gb_var_arg_5 GUARDED_BY(&mu1); int gb_var_arg_6 GUARDED_BY(muRef); int gb_var_arg_7 GUARDED_BY(muDoubleWrapper.getWrapper()->getMu()); int gb_var_arg_8 GUARDED_BY(muPointer); - +int gb_var_arg_9 GUARDED_BY(!&mu1); +int gb_var_arg_10 GUARDED_BY(!&*&mu1); // illegal attribute arguments int gb_var_arg_bad_1 GUARDED_BY(1); // \ |

