================ @@ -5137,47 +5137,41 @@ StringRef FunctionEffect::name() const { llvm_unreachable("unknown effect kind"); } -bool FunctionEffect::canInferOnFunction(const Decl &Callee) const { +std::optional<FunctionEffect> FunctionEffect::effectProhibitingInference( + const Decl &Callee, const FunctionEffectKindSet &CalleeFX) const { switch (kind()) { case Kind::NonAllocating: case Kind::NonBlocking: { - FunctionEffectsRef CalleeFX; - if (auto *FD = Callee.getAsFunction()) - CalleeFX = FD->getFunctionEffects(); - else if (auto *BD = dyn_cast<BlockDecl>(&Callee)) - CalleeFX = BD->getFunctionEffects(); - else - return false; - for (const FunctionEffectWithCondition &CalleeEC : CalleeFX) { + for (const FunctionEffect &Effect : CalleeFX) { // nonblocking/nonallocating cannot call allocating. - if (CalleeEC.Effect.kind() == Kind::Allocating) - return false; + if (Effect.kind() == Kind::Allocating) + return Effect; // nonblocking cannot call blocking. - if (kind() == Kind::NonBlocking && - CalleeEC.Effect.kind() == Kind::Blocking) - return false; + if (kind() == Kind::NonBlocking && Effect.kind() == Kind::Blocking) + return Effect; } - return true; + return std::nullopt; } case Kind::Allocating: case Kind::Blocking: - return false; + assert(0 && "effectProhibitingInference with non-inferable effect kind"); ---------------- dougsonos wrote:
Ah, I removed a more obviously superfluous assert for Kind::None, letting it fall into the llvm_unreachable. I didn't see this one at the time, and it does have a more useful message. Hm. https://github.com/llvm/llvm-project/pull/99656 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits