Add a new feature to display the call chain if an unsafe function is
found in a signal handler or function called from it.
Warning messages are improved too.
Details
- Reviewers
aaron.ballman njames93 alexfh hokein
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This needs tests demonstrating the notes. The defacto way is to replace all CHECK-MESSAGESDirectives with CHECK-NOTES. This'll for file check to look for lines containing note.
I tried to test the notes but could not get it to work. I think the problem is related to the fact that the notes are displayed at different locations that are past or before the current warning. The solution could be to manually specify line numbers in the CHECK-NOTE parts but I do not like this (and did not tried it). Or is there other solution?
The issue is FileCheck expects its directives to be in order they appear in the file being checked. Notes are always emitted just after the warning they are attached to.
So there are a few ways to go:
- use CHECK-NOTES-DAG to disregard the ordering and place them next to the location of the note in the code, to give correct line information.
- place the CHECK-NOTES directly after the warning they are attached.
Going with the first option makes it much harder to reason about.
Going with the second option you'll either have to just put a generic number regex for the line number, use (potentially large) relative @LINE offsets or absolute line numbers.
I think call stack may be useful for other checks too. May be code should be moved to utilities?
Yes it is useful for other checks, but the code here is specialized for this problem only. It is possible to make a call graph that stores the "parents" of the calls, probably root items that are of a special kind, and can add notes for call chain. But there is already a clang::CallGraph that can compute call graph, if I remember correctly it was not usable here because the parent node (caller) is not available. That CallGraph could be extended too.