[clang] [Clang] FunctionEffects: accept throw-only callees from noexcept callers (PR #238401)
Ambrose Leeb via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 10:46:09 PST 2026
================
@@ -125,6 +130,18 @@ static bool isNoexcept(const FunctionDecl *FD) {
return FPT && (FPT->isNothrow() || FD->hasAttr<NoThrowAttr>());
}
+static bool isNoexcept(const Decl *D) {
+ if (const auto *FD = D->getAsFunction())
+ return isNoexcept(FD);
+ if (const auto *BD = dyn_cast<BlockDecl>(D)) {
+ if (auto *TSI = BD->getSignatureAsWritten()) {
+ auto *FPT = TSI->getType()->castAs<FunctionProtoType>();
+ return FPT->isNothrow() || BD->hasAttr<NoThrowAttr>();
----------------
Sirraide wrote:
Ok, after reading that issue, I suppose the issue might just be that blocks are really weird. Can you have attributes that appertain to the type of a block w/o writing a parameter list? If yes, I wonder what type we return for that in `getSignatureAsWritten()` if it’s an attribute that changes the type (calling convention attributes do for instance). If you can’t... then I guess we just have to deal w/ the fact here that blocks sometimes might not have a FunctionProtoType—that said, if other parts of Clang make that assumption too, then we should probably just fix blocks (possibly by actually storing the function type and adding a `getType()` member or sth in that vein)
https://github.com/llvm/llvm-project/pull/238401
More information about the cfe-commits
mailing list