AaronBallman wrote:

> There's a problem with this attribute where the declaration in a header file 
> doesn't have the attribute, but the definition in the source file has. As a 
> result, the attribute doesn't take effect when just the header file is 
> included.

Errr, that's the behavior of basically all inheritable attributes -- the design 
idea there is that the attribute is additive information that's only visible 
from the declaration with the attribute onward. So I think some users will 
appreciate this warning because they might not have been aware that the 
attribute was not really doing much for them, but I also think some users will 
be frustrated because they've done things like:
```
// Source.cpp
void func();

void foo() {
  func(); // Doesn't know about the attribute, but that's intentional for 
whatever reason.
}

ATTR void func();

void bar() {
  func();  // Does see the attribute
}

void func() {}

void baz() {
  func(); // Still sees the attribute
}
```
I could imagine this being useful for `RequiresCapability` in cases where you 
only want to require the capability internally as an implementation detail, but 
not make it part of the public interface of the function.

@aaronpuchert -- do you have thoughts here?

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