Using clang::CallGraph to get the called functions.
This makes a better foundation to improve support for
C++ and print the call chain.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks for the cleanup, I like the direction this is heading. But is this actually NFC? I thought using a CallGraph would change the behavior in code like:
if (false) { // Statically known never to take this branch bad_call(); // Used to diagnose, does it still? }
but I could be remembering incorrectly.
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
129 | Should we also assert that this matcher is triggered before any other matcher is matched? Alternatively, instead of matching on the TU decl itself, would it make sense to walk the decl contexts up to the TU level on the first match? |
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
129 | The nicest solution would be to change the OnStartOfTranslationUnit callback to pass the ASTContext. That way checks which require setup code like this don't need to register matchers. |
The CallGraph just scans for FunctionDecl and CallExpr, no check for unreachable code is there.
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
129 | Call graph is now populated at the first normal match, no need for the additional AST matcher. |
LGTM aside from a commenting nit. Thanks!
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp | ||
---|---|---|
136 |
Should we also assert that this matcher is triggered before any other matcher is matched?
Alternatively, instead of matching on the TU decl itself, would it make sense to walk the decl contexts up to the TU level on the first match?