[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 30 01:36:28 PDT 2021
balazske added a comment.
The bug type is passed to `constructNoteTag` only to identify what message will be displayed. The bug types that are related to the current function (a message should be here if the bug is happening) are passed in. It should be enough to look at comment before `constructNoteTag` to check this (and to the bug type -> message map).
C.addTransition(StateFailed, constructNoteTag(C, StreamSym,
{&BT_StreamEof,
&BT_IndeterminatePosition}));
This indicates that if later an EOF error happens (function called in EOF state) this is the place to display a message "stream becomes EOF here". And if later an error "stream position indeterminate" happens the note should be here too, but with other message. So we can not have a single string as last parameter instead of the bug types. It is possible to add multiple note tags but I do not like it because this makes more `ExplodedNode`s. Or it is possible to figure out the needed message in the NoteTag function from the program state but this may be relatively difficult task and more code than the current solution.
================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:387-391
+ /// Create a NoteTag to display a note if a later bug report is generated.
+ /// The `BT` should contain all bug types that could be caused by the
+ /// operation at this location.
+ /// If later on the path a problematic event (reported bug) happens with the
+ /// same type, the last place is found with a note tag with that bug type.
----------------
balazske wrote:
> Szelethus wrote:
> > How about:
> >
> > Create a `NoteTag` describing an stream operation (whether stream opening succeeds or fails, stream reaches EOF, etc).
> > As not all operations are interesting for all types of stream bugs (the stream being at an indeterminate file position is irrelevant to whether it leaks or not), callers can specify in `BT` for which `BugType`s should this note be displayed for.
> > Only the `NoteTag` closest to the error location will be added to the bug report.
> The `NoteTag` is added at a place where a possible future bug is introduced. The bug type indicates which bug is the one that can happen after this event. If this bug is really detected the last NoteTag for this type (ignore other NoteTags with non-matching bug type) contains the relevant information.
This is the planned comment at `constructNoteTag`:
/// Create a NoteTag to display a note if a later bug report is generated.
/// This should be added added at a place where a possible future bug is
/// introduced. The bug type indicates which bug is the one that can happen
/// after this event. If this bug is really detected the last NoteTag for
/// its type (ignore other NoteTags with non-matching bug type) contains the
/// relevant information (location and text message).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106262/new/
https://reviews.llvm.org/D106262
More information about the cfe-commits
mailing list