[cfe-commits] r156005 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaCXX/warn-thread-safety-parsing.cpp

DeLesley Hutchins delesley at google.com
Wed May 2 10:38:37 PDT 2012


Author: delesley
Date: Wed May  2 12:38:37 2012
New Revision: 156005

URL: http://llvm.org/viewvc/llvm-project?rev=156005&view=rev
Log:
Thread Safety Analysis: fixed attribute handling for lock_returned attribute.

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=156005&r1=156004&r2=156005&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed May  2 12:38:37 2012
@@ -681,9 +681,14 @@
     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,

Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp?rev=156005&r1=156004&r2=156005&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp Wed May  2 12:38:37 2012
@@ -970,7 +970,7 @@
 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 @@
 class Graph {
 public:
   Mutex mu_;
+
+  static Mutex* get_static_mu() LOCK_RETURNED(&Graph::mu_);
 };
 
 class Node {





More information about the cfe-commits mailing list