[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 19 07:40:11 PDT 2023
balazske added a comment.
It is possible to add note tags to show decisions at standard functions. For example at `fileno` show if it has failed or not failed. The most simple way is to add it to all places, this means a note will show up on any bug path at all standard function usages. This is how it works already with the existing notes. Like in the following code:
int __test_case_note();
int test_case_note_1(int y) {
int x1 = __test_case_note(); // expected-note{{Function returns 1}}
int x = __test_case_note(); // expected-note{{Function returns 0}} \
// expected-note{{'x' initialized here}}
return y / x; // expected-warning{{Division by zero}} \
// expected-note{{Division by zero}}
}
int test_case_note_2(int y) {
int x = __test_case_note(); // expected-note{{Function returns 1}}
return y / (x - 1); // expected-warning{{Division by zero}} \
// expected-note{{Division by zero}}
}
Here the first note at line with "x1" is not necessary. This problem can be fixed if the note is only shown when the return value is "interesting":
int __test_case_note();
int test_case_note_1(int y) {
int x1 = __test_case_note(); // no note
int x = __test_case_note(); // expected-note{{Function returns 0}} \
// expected-note{{'x' initialized here}}
return y / x; // expected-warning{{Division by zero}} \
// expected-note{{Division by zero}}
}
int test_case_note_2(int y) {
int x = __test_case_note(); // no note
return y / (x - 1); // expected-warning{{Division by zero}} \
// expected-note{{Division by zero}}
}
But in this case the note at `test_case_note_2` disappears because `x-1` is interesting, but not `x`. Fixing this problem looks more difficult.
>From these two solutions, which one is better? (Show many unnecessary notes, or show only necessary ones but lose some of the useful notes too.)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152436/new/
https://reviews.llvm.org/D152436
More information about the cfe-commits
mailing list