[clang] nolock/noalloc attributes (PR #84983)
Doug Wyatt via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 14 17:36:21 PDT 2024
dougsonos wrote:
> > * Conversions between functions / function pointers with and without the attribute work in C++ but not in C and I'm a bit lost (there's a bunch of debug logging around this e.g. Sema::IsFunctionConversion and Sema::ImpCastExprToType)
I've probably been staring at this way too long, but here's what's going on. My test is:
```
void nolock(int) [[clang::nolock]];
void x() {
void (*fp_plain)(int);
fp_plain = nolock;
}
```
At the bottom of `checkPointerTypesForAssignment`:
```
llvm::outs() << "checkPointerTypesForAssignment calling IsFunctionConversion LHS " << ltrans << " RHS " << rtrans << "\n";
if (!S.getLangOpts().CPlusPlus &&
S.IsFunctionConversion(ltrans, rtrans, ltrans))
```
This prints `LHS void (int) RHS void (int) __attribute__((clang_nolock))`
Then inside isFunctionConversion, I immediately log:
```
llvm::outs() << "IsFunctionConversion: " << FromType << " -> " << ToType
<< "\n";
```
and it's `void (int) -> void (int) __attribute__((clang_nolock))`
Reconciliation of the FunctionEffectSets on the two types is needed, but I'm confused right from the beginning here; the naming of "From" and "To" seems backwards. Would appreciate any pointers.
https://github.com/llvm/llvm-project/pull/84983
More information about the cfe-commits
mailing list