================ @@ -6298,10 +6308,60 @@ static bool isImmediateSinkBlock(const CFGBlock *Blk) { // at least for now, but once we have better support for exceptions, // we'd need to carefully handle the case when the throw is being // immediately caught. - if (llvm::any_of(*Blk, [](const CFGElement &Elm) { + if (llvm::any_of(*Blk, [](const CFGElement &Elm) -> bool { + if (std::optional<CFGStmt> StmtElm = Elm.getAs<CFGStmt>()) + return isa<CXXThrowExpr>(StmtElm->getStmt()); + return false; + })) + return true; + + auto HasNoReturnCall = [&](const CallExpr *CE) { + if (!CE) + return false; + + auto *FD = CE->getDirectCallee(); + + if (!FD) + return false; + + auto *CanCD = FD->getCanonicalDecl(); + auto *DefFD = CanCD->getDefinition(); + auto NoRetAttrOpt = CanCD->getAnalyzerNoReturn(); + auto NoReturn = false; + + if (!NoRetAttrOpt && DefFD && DefFD->getBody()) { + // HACK: we are gonna cache analysis result as implicit + // `analyzer_noreturn` attribute + auto *MutCD = const_cast<FunctionDecl *>(CanCD); + + // Mark function as `analyzer_noreturn(false)` to: + // * prevent infinite recursion in noreturn analysis + // * indicate that we've already analyzed(-ing) this function + // * serve as a safe default assumption (function may return) + MutCD->addAttr(AnalyzerNoReturnAttr::CreateImplicit( + CanCD->getASTContext(), false, CanCD->getLocation())); + + auto CalleeCFG = ---------------- negativ wrote:
@steakhal @Xazax-hun I'm thinking about making this feature configurable through a flag. It will clearly have significant performance implications, but it's really only required for specific use cases (like clang-tidy checkers). It might be safer to explicitly opt-in only where necessary and where performance drops are more acceptable (e.g., in the unchecked-optional-access checker) https://github.com/llvm/llvm-project/pull/146355 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits