[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-13 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-13 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-13 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Arthur Eubanks via cfe-commits
aeubanks wrote: > @aeubanks I'll revert. Is this example C or C++? C++ 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Dan Liew via cfe-commits
delcypher wrote: @pdherbemont Could you take a look at this? 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Dan Liew via cfe-commits
delcypher wrote: Reverted in c9d580033f29196223cd56a0fa238c3ba51d23e4 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Dan Liew via cfe-commits
delcypher wrote: @aeubanks I'll revert. Is this example C or C++? 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Arthur Eubanks via cfe-commits
aeubanks wrote: reduced: ``` struct Lock {}; struct A { Lock lock; union { bool b __attribute__((guarded_by(lock))); }; }; ``` seems like a regression, can we revert for now? https://github.com/llvm/llvm-project/pull/94216

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Arthur Eubanks via cfe-commits
aeubanks wrote: this seems to have broken code like [this](https://crsrc.org/c/base/allocator/partition_allocator/src/partition_alloc/random.cc;drc=36293863bf9bbc8131797eb8f4d2bafe8af3de79;l=33) with ``` ../../base/allocator/partition_allocator/src/partition_alloc/random.cc:33:69: error:

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Dan Liew via cfe-commits
delcypher wrote: @pdherbemont I've landed on your behalf. I tweaked the commit message to be more descriptive of the change we finally landed and noted that you are the author of this patch. Thanks again for working on this :) https://github.com/llvm/llvm-project/pull/94216

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread via cfe-commits
github-actions[bot] wrote: @pdherbemont Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Dan Liew via cfe-commits
https://github.com/delcypher closed 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Dan Liew via cfe-commits
https://github.com/delcypher approved this pull request. Thanks for fixing my requested changes. LGTM https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-10 Thread Pierre d'Herbemont via cfe-commits
@@ -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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-10 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Dan Liew via cfe-commits
@@ -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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Dan Liew via cfe-commits
@@ -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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
@@ -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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
@@ -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!

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-07 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -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 delcypher wrote: @pdherbemont We should

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -3330,6 +3340,112 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute( +IdentifierInfo , SourceLocation AttrNameLoc, +ParsedAttributes ,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
https://github.com/delcypher edited 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
@@ -29,6 +29,13 @@ struct LOCKABLE Mutex {}; struct Foo { struct Mutex *mu_; + int a_value GUARDED_BY(mu_); delcypher wrote: @pdherbemont I think you should be checking **both** late and regular parsing for all attributes that you're adding support for.

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Dan Liew via cfe-commits
https://github.com/delcypher requested changes to this pull request. @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.

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman approved this pull request. LGTM! Do you need someone to land these changes on your behalf? https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-06 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna approved this pull request. LGTM assuming you will be fixing the buildkite failures. You may still need to wait on @AaronBallman's approval. https://github.com/llvm/llvm-project/pull/94216 ___ cfe-commits mailing list

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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 > > >

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Yeoul Na via cfe-commits
rapidsna 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute(IdentifierInfo , + SourceLocation

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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 > > >

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Aaron Ballman via cfe-commits
AaronBallman 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!

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll commented: `Sema.h` changes look good to me. 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
@@ -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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
@@ -671,6 +671,16 @@ void Parser::ParseGNUAttributeArgs( ParseBoundsAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc, Form); return; + } else if (AttrKind == ParsedAttr::AT_GuardedBy) { +ParseGuardedByAttribute(*AttrName,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute(IdentifierInfo , + SourceLocation

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-05 Thread Pierre d'Herbemont via cfe-commits
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!

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Yeoul Na via cfe-commits
@@ -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_); rapidsna wrote: Nit: Please check indent

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Yeoul Na via cfe-commits
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute(IdentifierInfo , + SourceLocation

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna edited 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Yeoul Na via cfe-commits
https://github.com/rapidsna commented: You may also want to consider making the attribute late parsed in C when `-fexperimental-late-parse-attributes` is enabled. See

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Aaron Ballman via cfe-commits
@@ -671,6 +671,16 @@ void Parser::ParseGNUAttributeArgs( ParseBoundsAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc, Form); return; + } else if (AttrKind == ParsedAttr::AT_GuardedBy) { +ParseGuardedByAttribute(*AttrName,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Aaron Ballman via cfe-commits
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute(IdentifierInfo , + SourceLocation

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman commented: Thank you for working on this! The changes should come with a release note in clang/docs/ReleaseNotes.rst so users know about the new functionality. One question I have is whether there will be follow-up work for other thread safety attributes

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Aaron Ballman via cfe-commits
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute(IdentifierInfo , + SourceLocation

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Aaron Ballman via cfe-commits
https://github.com/AaronBallman edited 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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Pierre d'Herbemont via cfe-commits
@@ -3330,6 +3340,63 @@ void Parser::DistributeCLateParsedAttrs(Decl *Dcl, } } +/// GuardedBy attributes (e.g., guarded_by): +/// AttrName '(' expression ')' +void Parser::ParseGuardedByAttribute(IdentifierInfo , + SourceLocation

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-04 Thread Pierre d'Herbemont via cfe-commits
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

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-03 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Pierre d'Herbemont (pdherbemont) Changes 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. --- Full diff:

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-03 Thread via cfe-commits
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you,

[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-03 Thread Pierre d'Herbemont via 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