[clang] [clang][ThreadSafety] Warn when constructor is trylock (PR #95290)

Dan McArdle via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 20 14:55:36 PDT 2024


================
@@ -614,9 +619,23 @@ static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL,
     return false;
   }
 
-  // check that all arguments are lockable objects
+  // Check that all remaining arguments are lockable objects.
   checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1);
 
+  // Check that the attribute is applied to a function.
+  if (!D->isFunctionOrFunctionTemplate()) {
----------------
dmcardle wrote:

Indeed it is not! Thanks for flagging.

https://github.com/llvm/llvm-project/pull/95290


More information about the cfe-commits mailing list