Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>,
Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>,
Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>,
Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>,
Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/67...@github.com>


tbaederr wrote:

Hmm, so this is causing problems:

```c++

namespace DoubleLockBug {
  class Foo {
  public:
    Mutex mu_;
    int a GUARDED_BY(mu_);
    void foo1() EXCLUSIVE_LOCKS_REQUIRED(mu_);
  };
  void Foo::foo1() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
    a = 0;
  }
}
```

The AST is:
```
CXXMethodDecl 0x7d3d96ebf710 parent 0x7d3d96ebf118 prev 0x7d3d96ebf450 
<./array.cpp:57:3, line:59:3> line:57:13 foo1 'void ()'
|-CompoundStmt 0x7d3d96ebfa70 <col:50, line:59:3>
| `-BinaryOperator 0x7d3d96ebfa48 <line:58:5, col:9> 'int' lvalue '='
|   |-MemberExpr 0x7d3d96ebf9e8 <col:5> 'int' lvalue ->a 0x7d3d96ebf398
|   | `-CXXThisExpr 0x7d3d96ebf9d0 <col:5> 'DoubleLockBug::Foo *' implicit this
|   `-IntegerLiteral 0x7d3d96ebfa20 <col:9> 'int' 0
|-RequiresCapabilityAttr 0x7d3d96ebf890 <line:15:56, col:92> Inherited 
exclusive_locks_required
| `-MemberExpr 0x7d3d96ebf5f8 <line:55:42> 'Mutex' lvalue ->mu_ 0x7d3d96ebf328 
non_odr_use_unevaluated
|   `-CXXThisExpr 0x7d3d96ebf5e0 <col:42> 'DoubleLockBug::Foo *' implicit this
`-RequiresCapabilityAttr 0x7d3d96ebf930 <line:15:56, col:92> 
exclusive_locks_required
  `-MemberExpr 0x7d3d96ebf8f8 <line:57:45> 'Mutex' lvalue ->mu_ 0x7d3d96ebf328 
non_odr_use_unevaluated
    `-CXXThisExpr 0x7d3d96ebf8e0 <col:45> 'DoubleLockBug::Foo *' implicit this

CXXMethodDecl 0x7d3d96ebf450 <./array.cpp:55:5, line:15:94> line:55:10 foo1 
'void ()'
`-RequiresCapabilityAttr 0x7d3d96ebf630 <line:15:56, col:92> 
exclusive_locks_required
  `-MemberExpr 0x7d3d96ebf5f8 <line:55:42> 'Mutex' lvalue ->mu_ 0x7d3d96ebf328 
non_odr_use_unevaluated
    `-CXXThisExpr 0x7d3d96ebf5e0 <col:42> 'DoubleLockBug::Foo *' implicit this
```

So the definition has `mu_` twice, which causes us to diagnose mismatching 
attributes. Is there any sort of facility to deduplicate capabilities? 
Declaring a `std::set` of `CapabilityExpr` doesn't seem to work because there's 
no `operator<` for those.

https://github.com/llvm/llvm-project/pull/67520
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to