[PATCH] D118224: [clang-tidy] bugprone-signal-handler improvements: display call chain
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 26 06:42:09 PST 2022
balazske added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:199-200
+ const FunctionDecl *HandlerDecl, const Expr *HandlerRef) {
+ int CallLevel = Itr.getPathLength() - 2;
+ const CallGraphNode *Caller = Itr.getPath(CallLevel + 1), *Callee = nullptr;
+ while (CallLevel >= 0) {
----------------
aaron.ballman wrote:
> Do we have to worry about `CallLevel + 1` being negative here? (Is there a need for an assert?)
Really yes, but here is no assert because it is on line 161 and the function is called only there. A `df_iterator` path contains the start and end node, and there should be at least one function if we have any report do show, the path length should be at least 1 (make assert for that?). (Later there could be cases when the function is called with path length 1.)
================
Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:207-208
+ DiagnosticIDs::Note)
+ << cast<FunctionDecl>(Callee->getDecl())
+ << cast<FunctionDecl>(Caller->getDecl());
+ --CallLevel;
----------------
aaron.ballman wrote:
> Do we have to worry about call expressions for which we cannot find the declaration (like a call through a function pointer)? (Should we add some test coverage involving a call stack with a call through a function pointer?)
A declaration should always be there in the `CallGraphNode`, probably not a definition. The call graph does not insert nodes for function pointer calls.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118224/new/
https://reviews.llvm.org/D118224
More information about the cfe-commits
mailing list