aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeLesley Hutchins <delesley@google.com>2012-05-02 17:38:37 +0000
committerDeLesley Hutchins <delesley@google.com>2012-05-02 17:38:37 +0000
commitf26efd79d1bd139641d0bb40842f908c67f041c2 (patch)
treeaa550ce19e46bd7beb5096c0ce213f5dc18ec03b
parentf5eac481ab6da79f05ca13fd859b67abfd2ed246 (diff)
Thread Safety Analysis: fixed attribute handling for lock_returned attribute.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156005 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclAttr.cpp9
-rw-r--r--test/SemaCXX/warn-thread-safety-parsing.cpp4
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index c8af3a430a..13bf0aa487 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -681,9 +681,14 @@ static void handleLockReturnedAttr(Sema &S, Decl *D,
return;
// check that the argument is lockable object
- checkForLockableRecord(S, D, Attr, Arg->getType());
+ SmallVector<Expr*, 1> Args;
+ checkAttrArgsAreLockableObjs(S, D, Attr, Args);
+ unsigned Size = Args.size();
+ if (Size == 0)
+ return;
- D->addAttr(::new (S.Context) LockReturnedAttr(Attr.getRange(), S.Context, Arg));
+ D->addAttr(::new (S.Context) LockReturnedAttr(Attr.getRange(), S.Context,
+ Args[0]));
}
static void handleLocksExcludedAttr(Sema &S, Decl *D,
diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp
index 40837eab2e..316bcf74ad 100644
--- a/test/SemaCXX/warn-thread-safety-parsing.cpp
+++ b/test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -970,7 +970,7 @@ int lr_function_8() LOCK_RETURNED(muPointer);
int lr_function_bad_1() LOCK_RETURNED(1); // \
// expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_2() LOCK_RETURNED("mu"); // \
- // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
+ // expected-warning {{ignoring 'lock_returned' attribute because its argument is invalid}}
int lr_function_bad_3() LOCK_RETURNED(muDoublePointer); // \
// expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}}
int lr_function_bad_4() LOCK_RETURNED(umu); // \
@@ -1350,6 +1350,8 @@ void testEmptyAttributeFunction() EXCLUSIVE_LOCKS_REQUIRED("");
class Graph {
public:
Mutex mu_;
+
+ static Mutex* get_static_mu() LOCK_RETURNED(&Graph::mu_);
};
class Node {