[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/81842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/81842 From 0f836d8e63f462f57784e62bcd87ac1f4f5a3d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 15 Feb 2024 10:56:32 +0100 Subject: [PATCH 1/3] [clang][analyzer] Change modeling of 'f

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread Ben Shi via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: @@ -1404,6 +1486,47 @@ void StreamChecker::evalFeofFerror(const FnDescription *Desc, } } +void StreamChecker::evalFileno(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C)

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread Ben Shi via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= Message-ID: In-Reply-To: @@ -268,6 +268,16 @@ void test_clearerr(FILE *F) { // expected-warning@-1{{FALSE}} } +void test_fileno(FILE *F) { + errno = 0; + int A = fileno(F); + clang_analyzer_eval(F != NU

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread Ben Shi via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= Message-ID: In-Reply-To: https://github.com/benshi001 approved this pull request. https://github.com/llvm/llvm-project/pull/81842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bi

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread Ben Shi via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: https://github.com/benshi001 edited https://github.com/llvm/llvm-project/pull/81842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread via cfe-commits
=?utf-8?q?Balázs_Kéri?= Message-ID: In-Reply-To: https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/81842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= Message-ID: In-Reply-To: https://github.com/NagyDonat approved this pull request. LGTM, thanks for the update! The new `getZeroVal()` is a nice simplification. https://github.com/llvm/llvm-project/pull/81842 ___ cf

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-20 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/81842 From 0f836d8e63f462f57784e62bcd87ac1f4f5a3d00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 15 Feb 2024 10:56:32 +0100 Subject: [PATCH 1/2] [clang][analyzer] Change modeling of 'f

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-16 Thread via cfe-commits
@@ -1404,6 +1486,47 @@ void StreamChecker::evalFeofFerror(const FnDescription *Desc, } } +void StreamChecker::evalFileno(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + // Fileno should fail only if the passed

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-16 Thread via cfe-commits
@@ -1404,6 +1486,47 @@ void StreamChecker::evalFeofFerror(const FnDescription *Desc, } } +void StreamChecker::evalFileno(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + // Fileno should fail only if the passed

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-16 Thread via cfe-commits
https://github.com/NagyDonat approved this pull request. LGTM with some low priority bikeshedding in a comment. By the way it would be good to rebase this change onto your other commit #79312 (that was merged a few hours ago) and use the "toolbox" introduced there if that's possible. https://

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-16 Thread via cfe-commits
https://github.com/NagyDonat edited https://github.com/llvm/llvm-project/pull/81842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-15 Thread Balázs Kéri via cfe-commits
balazske wrote: Additionally code of `fflush` is moved in `StreamChecker` to a better place. https://github.com/llvm/llvm-project/pull/81842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-15 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-static-analyzer-1 Author: Balázs Kéri (balazske) Changes Function 'fileno' fails only if invalid pointer is passed, this is a case that is often ignored in source code. The failure case leads to many "false positive" (t

[clang] [clang][analyzer] Change modeling of 'fileno' in checkers. (PR #81842)

2024-02-15 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/81842 Function 'fileno' fails only if invalid pointer is passed, this is a case that is often ignored in source code. The failure case leads to many "false positive" (theoretically correct bug normally "should not ha