[clang] [clang] WIP: Warn on mismatched RequiresCapability attributes (PR #67520)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 14:24:00 PDT 2024


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


https://github.com/aaronpuchert commented:

So the semantics here are: if there is any `requires_capability` attribute on a function, it needs to exactly match the set of `requires_capability` attributes on every previous declaration? Or in other words: the attributes are either inherited or need to be exactly repeated? To me that sounds fine, just wanted to clarify it.

It seems that inheritance results in duplicated attributes, but we eliminate those duplicates in `ThreadSafetyAnalyzer::getMutexIDs` based on `CapabilityExpr::equals`. If we want to allow repetition, we should probably compare in the same way. Which means we probably need to move this back into `ThreadSafety.cpp`, even though it's an attribute warning. (I don't think we want to use Thread Safety internals in Sema.)

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


More information about the cfe-commits mailing list