@@ -29,6 +30,22 @@ struct LOCKABLE Mutex {};
struct Foo {
struct Mutex *mu_;
+ int a_value GUARDED_BY(mu_);
+
+ struct Bar {
+struct Mutex *other_mu ACQUIRED_AFTER(mu_);
pdherbemont wrote:
> I'm not entirely sure how nested structs work in C, but sho
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/95455
>From 4edb5194a6c03cf7bcf18eb998728da7cbc51dc0 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 12 Jun 2024 20:20:05 +0200
Subject: [PATCH] Support `guarded_by` attribute and related attributes in
@@ -764,12 +764,6 @@ doesn't know that munl.mu == mutex. The SCOPED_CAPABILITY
attribute handles
aliasing for MutexLocker, but does so only for that particular pattern.
-ACQUIRED_BEFORE(...) and ACQUIRED_AFTER(...) are currently unimplemented.
--
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/95455
>From 2a8eb78119421fa63f635f9f4e5edad18c635d9c Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 12 Jun 2024 20:20:05 +0200
Subject: [PATCH] Support `guarded_by` attribute and related attributes in
pdherbemont wrote:
> LGTM. Let me know if you need me to merge this change.
Yes, please!
https://github.com/llvm/llvm-project/pull/95455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit
pdherbemont wrote:
> One question I have is whether there will be follow-up work for other thread
> safety attributes (`acquire_capability`, `try_acquire_capability`, etc)?
They already work fine in C so far. But if you are aware of some issues don't
hesitate to let me know!
https://github.co
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 0fd6864d7f0a85ca82f3c926a51403383c7ea0c7 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] attribute inside C struct
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 7d01e8aae371e02f23b118d5b92f39fcee72723f Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] attribute inside C struct
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(IdentifierInfo &AttrName,
+ SourceLocation
@@ -671,6 +671,16 @@ void Parser::ParseGNUAttributeArgs(
ParseBoundsAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc,
Form);
return;
+ } else if (AttrKind == ParsedAttr::AT_GuardedBy) {
+ParseGuardedByAttribute(*AttrName, AttrNa
@@ -28,7 +28,12 @@
struct LOCKABLE Mutex {};
struct Foo {
- struct Mutex *mu_;
+struct Mutex *mu_;
+struct Bar {
+struct Mutex *other_mu;
+} bar;
+ int a_value GUARDED_BY(mu_);
pdherbemont wrote:
Fixed
https://github.com/llvm/llvm-proj
pdherbemont wrote:
> You may also want to consider making the attribute late parsed in C when
> `-fexperimental-late-parse-attributes` is enabled. See
> https://github.com/llvm/llvm-project/pull/93121/files#diff-ae2ec9524bdbeea1f06917607482634dd89af5bcbb929805032463e5dafe79e7R2260
>
> That wil
pdherbemont wrote:
> > > One question I have is whether there will be follow-up work for other
> > > thread safety attributes (`acquire_capability`, `try_acquire_capability`,
> > > etc)?
> >
> >
> > They already work fine in C so far. But if you are aware of some issues
> > don't hesitate to
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 94212789ca0b22380de88521279056ffdce5b3e6 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 94212789ca0b22380de88521279056ffdce5b3e6 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH 1/2] Support [[guarded_by(mutex)]] and friends attributes
pdherbemont wrote:
> > > > One question I have is whether there will be follow-up work for other
> > > > thread safety attributes (`acquire_capability`,
> > > > `try_acquire_capability`, etc)?
> > >
> > >
> > > They already work fine in C so far. But if you are aware of some issues
> > > don
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(IdentifierInfo &AttrName,
+ SourceLocation
pdherbemont wrote:
Pushed an additional change on the documentation: the doc was incorrectly
stating that ACQUIRED_{AFTER,BEFORE} were not implemented but they are.
https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commi
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From bb2effbaf8e06ae933791d8533c006a6db3aadc9 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 0f7d369ac81fd9523e90404c6b863baaf1f6afd9 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
pdherbemont wrote:
> `-fexperimental-late-parse-attributes`
Done
> > > You may also want to consider making the attribute late parsed in C when
> > > `-fexperimental-late-parse-attributes` is enabled. See
> > > https://github.com/llvm/llvm-project/pull/93121/files#diff-ae2ec9524bdbeea1f069176
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 313335523ecdfec8cbf7e703cb720bb4adc81a52 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 958ff53f3c3f31550e093494d5240ec1f350124e Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 48f2f8c92ca268f1c92c36b77a5a84a6cd921de9 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
pdherbemont wrote:
> LGTM assuming you will be fixing the buildkite failures.
>
> You may still need to wait on @AaronBallman's approval.
Fixed the buildkite issue – they were regression from the latest changes about
acquired_{before,after} handling. Also pinged @AaronBallman. Thank you all fo
pdherbemont wrote:
> LGTM! Do you need someone to land these changes on your behalf?
Yes – that would be ideal! Thanks :)
https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cg
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 55eb00bafdd19817a2c31af6178a301582f5523b Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta
%s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta
-fexperimental-late-parse-attributes %s
pdherbemont wrote:
done!
https://github.com
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(
+IdentifierInfo &AttrName, SourceLocation AttrNameLoc,
+ParsedAttrib
@@ -29,6 +29,13 @@ struct LOCKABLE Mutex {};
struct Foo {
struct Mutex *mu_;
+ int a_value GUARDED_BY(mu_);
pdherbemont wrote:
done!
https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(
+IdentifierInfo &AttrName, SourceLocation AttrNameLoc,
+ParsedAttrib
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(
+IdentifierInfo &AttrName, SourceLocation AttrNameLoc,
+ParsedAttrib
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(
+IdentifierInfo &AttrName, SourceLocation AttrNameLoc,
+ParsedAttrib
pdherbemont wrote:
> @pdherbemont thanks for working on this. It looks pretty good and its great
> to see the late parsing support I added gaining new users. I just have some
> nits about missing test cases.
I should have added all the requested test cases. Not sure it's the way you
wanted it
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From a9da7c1287142025d8a54e569f6c5f8ecb411961 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] and friends attributes ins
@@ -74,6 +83,15 @@ int get_value(int *p) SHARED_LOCKS_REQUIRED(foo_.mu_){
void unlock_scope(struct Mutex *const *mu)
__attribute__((release_capability(**mu)));
+// Verify late parsing:
+#ifdef LATE_PARSING
+struct LateParsing {
+ int a_value_defined_before GUARDED_BY(a_mute
pdherbemont wrote:
Ah nice catch! Thank you @aeubanks and @delcypher – I am going to try to
understand why (and add a new test)
https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.
pdherbemont wrote:
So I found the cause of the regression: We used to parse the argument in an
`Unevaluated` context in C++ mode. We now parse them in a
`PotentiallyEvaluated` context. Switching to `Unevaluated` makes the C parsing
code fail. A simple fix is to switch the context based on the
https://github.com/pdherbemont created
https://github.com/llvm/llvm-project/pull/95455
This fixes #20777. This replaces #94216 which was reverted after being merged.
Previously the `guarded_by`, `pt_guarded_by`, `acquired_after`, and
`acquired_before` attributes were only supported inside C++
pdherbemont wrote:
Follow-up PR #95455
https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/95455
>From 783a6b58367d99eb4b2be3ee1d7177419138885b Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 12 Jun 2024 20:20:05 +0200
Subject: [PATCH] Support `guarded_by` attribute and related attributes in
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/95455
>From 8bfc79e42062e1343dbf96faadcd48cb55134079 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 12 Jun 2024 20:20:05 +0200
Subject: [PATCH] Support `guarded_by` attribute and related attributes in
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/95455
>From db251415e4e8c110d8842b1242d51d6ec5e839e5 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 12 Jun 2024 20:20:05 +0200
Subject: [PATCH] Support `guarded_by` attribute and related attributes in
@@ -3330,6 +3340,118 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(
+IdentifierInfo &AttrName, SourceLocation AttrNameLoc,
+ParsedAttrib
@@ -1,10 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta
%s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -Wthread-safety-beta
-fexperimental-late-parse-attributes -DLATE_PARSING %s
#define LOCKABLE__attribute__
https://github.com/pdherbemont edited
https://github.com/llvm/llvm-project/pull/95455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/pdherbemont edited
https://github.com/llvm/llvm-project/pull/95455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
https://github.com/pdherbemont created
https://github.com/llvm/llvm-project/pull/94216
Today, it's only supported inside C++ classes or top level C/C++
declaration.
I mostly copied and adapted over the code from the
[[counted_by(value)]] lookup.
>From 7b5c9e566c326a16d192ae478c806cbc
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From ccf6699197b608f95deea2b03b1ee87e29fbc8e1 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] attribute inside C struct
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From bf9a2ba20be8271c30fef456536dd058d599b4cc Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] attribute inside C struct
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/94216
>From 3cfee204f62e029fb1aaadae6a598e1d46b5c465 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 29 May 2024 11:11:03 +0200
Subject: [PATCH] Support [[guarded_by(mutex)]] attribute inside C struct
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl,
}
}
+/// GuardedBy attributes (e.g., guarded_by):
+/// AttrName '(' expression ')'
+void Parser::ParseGuardedByAttribute(IdentifierInfo &AttrName,
+ SourceLocation
pdherbemont wrote:
> Thank you for these changes! Can you also add a release note to
> `clang/docs/ReleaseNotes.rst` so users know about the new attribute spellings?
They are already sort of documented as such – but will update the
ReleaseNotes.rst.
Does anyone know why the new names were doc
https://github.com/pdherbemont created
https://github.com/llvm/llvm-project/pull/99919
For some reason some attributes weren't renamed in code but were
documented with the new names. I am not sure why this was the case and
maybe I am missing something.
Those are:
- scoped_lockable -> scoped_cap
https://github.com/pdherbemont updated
https://github.com/llvm/llvm-project/pull/95455
>From 4fc74f23410c954d83d5e99fc20b78a4e1044834 Mon Sep 17 00:00:00 2001
From: Pierre d'Herbemont
Date: Wed, 12 Jun 2024 20:20:05 +0200
Subject: [PATCH] Support `guarded_by` attribute and related attributes in
pdherbemont wrote:
> @pdherbemont Thanks for working on this LGTM. Please confirm that the
> comments that @aaronpuchert wanted have been added because I couldn't see
> them.
>
> Once you've done that we can get this merged :)
Done!
https://github.com/llvm/llvm-project/pull/95455
___
pdherbemont wrote:
I think this still needs review from @delcypher and @rapidsna
https://github.com/llvm/llvm-project/pull/95455
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
57 matches
Mail list logo