[PATCH] D153458: [clang-tidy] Model noexcept more properly in bugprone-exception-escape
Domján Dániel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 23 12:02:02 PDT 2023
isuckatcs added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:319
+static bool cannotThrow(const FunctionDecl *Func) {
+ const auto *FunProto = Func->getType()->getAs<FunctionProtoType>();
----------------
Put this in the anonymous namespace above please to remain consistent.
================
Comment at: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp:446
+ if (!Func || CallStack.count(Func) ||
+ (!CallStack.empty() && cannotThrow(Func)))
return ExceptionInfo::createNonThrowing();
----------------
Is `cannotThrow(Func)` really needed here? Isn't it possible to bail out after the body of the function has been analyzed?
I understand that you want to prevent some recursive calls and bail out early, but I don't think that it worths adding some additional logic, which is not needed anyway.
If you really want to optimize this or you're worried about stack overflows, consider rewriting the recursive solution to an iterative one.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153458/new/
https://reviews.llvm.org/D153458
More information about the cfe-commits
mailing list