[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
@@ -324,6 +343,60 @@ void error_fseek_0(void) { fclose(F); } +void error_fseeko_0(void) { + FILE *F = fopen("file", "r"); + if (!F) +return; + int rc = fseeko(F, 0, SEEK_SET); + if (rc) { +int IsFEof = feof(F), IsFError = ferror(F); +// Get ferror or no error

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
@@ -268,8 +268,12 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ASTImporter] Improve import of friend class templates. (PR #74627)

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

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

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

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

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

[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)

2024-01-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. https://github.com/llvm/llvm-project/pull/77580 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] c5d83cd - [clang][ASTImporter] Fix a bug when importing CXXDefaultInitExpr.

2022-03-28 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-03-28T10:55:26+02:00 New Revision: c5d83cdca457fd024a3f76c5e2ba649462ecde67 URL: https://github.com/llvm/llvm-project/commit/c5d83cdca457fd024a3f76c5e2ba649462ecde67 DIFF: https://github.com/llvm/llvm-project/commit/c5d83cdca457fd024a3f76c5e2ba649462ecde67.diff L

[clang] 501faaa - [clang][analyzer] Add more wide-character functions to CStringChecker

2022-08-05 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-08-05T10:32:53+02:00 New Revision: 501faaa0d65e9814566ef65e58d834c13b8a URL: https://github.com/llvm/llvm-project/commit/501faaa0d65e9814566ef65e58d834c13b8a DIFF: https://github.com/llvm/llvm-project/commit/501faaa0d65e9814566ef65e58d834c13b8a.diff L

[clang] d4ff9ef - [clang][ASTImporter] Improve import of functions with auto return type.

2022-08-09 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-08-09T09:20:06+02:00 New Revision: d4ff9eff767c24716b5654780bc2e48c2017b4c5 URL: https://github.com/llvm/llvm-project/commit/d4ff9eff767c24716b5654780bc2e48c2017b4c5 DIFF: https://github.com/llvm/llvm-project/commit/d4ff9eff767c24716b5654780bc2e48c2017b4c5.diff L

[clang-tools-extra] a772f77 - [clang-tidy] Support C++14 in bugprone-signal-handler.

2022-08-10 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-08-10T12:00:16+02:00 New Revision: a772f775a2ba401e95a0bbe73deb6300f1dc12c0 URL: https://github.com/llvm/llvm-project/commit/a772f775a2ba401e95a0bbe73deb6300f1dc12c0 DIFF: https://github.com/llvm/llvm-project/commit/a772f775a2ba401e95a0bbe73deb6300f1dc12c0.diff L

[clang] b0d38ad - [clang][Analyzer] Add symbol uninterestingness to bug report.

2021-07-15 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2021-07-15T10:02:18+02:00 New Revision: b0d38ad0bc254b887123cd063a5f0db30a80f938 URL: https://github.com/llvm/llvm-project/commit/b0d38ad0bc254b887123cd063a5f0db30a80f938 DIFF: https://github.com/llvm/llvm-project/commit/b0d38ad0bc254b887123cd063a5f0db30a80f938.diff L

[clang] 90cb529 - [clang][analyzer] Improve report of file read at EOF condition (alpha.unix.Stream checker).

2021-07-20 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2021-07-21T08:54:11+02:00 New Revision: 90cb5297adf086073f14d455050b5cde9a03503d URL: https://github.com/llvm/llvm-project/commit/90cb5297adf086073f14d455050b5cde9a03503d DIFF: https://github.com/llvm/llvm-project/commit/90cb5297adf086073f14d455050b5cde9a03503d.diff L

[clang] 41adc09 - [clang][AST] Add support for DecompositionDecl to ASTImporter.

2021-07-22 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2021-07-22T13:09:42+02:00 New Revision: 41adc09b221170065e227f43c7fd21ffce5e2a6e URL: https://github.com/llvm/llvm-project/commit/41adc09b221170065e227f43c7fd21ffce5e2a6e DIFF: https://github.com/llvm/llvm-project/commit/41adc09b221170065e227f43c7fd21ffce5e2a6e.diff L

[clang-tools-extra] cc7ed0c - [clang-tidy] bugprone-signal-handler: Message improvement and code refactoring.

2022-04-07 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-04-07T09:38:58+02:00 New Revision: cc7ed0caaca58bb38c789dcf2e0aade5f68f1e02 URL: https://github.com/llvm/llvm-project/commit/cc7ed0caaca58bb38c789dcf2e0aade5f68f1e02 DIFF: https://github.com/llvm/llvm-project/commit/cc7ed0caaca58bb38c789dcf2e0aade5f68f1e02.diff L

[clang] 5479174 - [clang][ASTImporter] Not using consumeError at failed import of in-class initializer.

2022-04-07 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-04-07T11:07:15+02:00 New Revision: 5479174071ec7d4692959bbdc15b5bb79e268e00 URL: https://github.com/llvm/llvm-project/commit/5479174071ec7d4692959bbdc15b5bb79e268e00 DIFF: https://github.com/llvm/llvm-project/commit/5479174071ec7d4692959bbdc15b5bb79e268e00.diff L

[clang] 2b6e5fa - [clang][ASTImporter] Add import of attribute 'enable_if'.

2022-04-12 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-04-12T10:02:51+02:00 New Revision: 2b6e5fa62b80f4c0ca540e2fc0ebe3b15e50b78a URL: https://github.com/llvm/llvm-project/commit/2b6e5fa62b80f4c0ca540e2fc0ebe3b15e50b78a DIFF: https://github.com/llvm/llvm-project/commit/2b6e5fa62b80f4c0ca540e2fc0ebe3b15e50b78a.diff L

[clang] 5967528 - [clang][ASTImporter] Fix an import error handling related bug.

2022-04-13 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-04-13T10:11:33+02:00 New Revision: 596752863e27e6b4b89e34ecfcf5317a5bf46b52 URL: https://github.com/llvm/llvm-project/commit/596752863e27e6b4b89e34ecfcf5317a5bf46b52 DIFF: https://github.com/llvm/llvm-project/commit/596752863e27e6b4b89e34ecfcf5317a5bf46b52.diff L

[clang-tools-extra] c63522e - [clang-tidy] Add new check 'shared-ptr-array-mismatch'.

2022-02-07 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-02-07T12:57:58+01:00 New Revision: c63522e6ba7782c335043893ae7cbd37eca24fe5 URL: https://github.com/llvm/llvm-project/commit/c63522e6ba7782c335043893ae7cbd37eca24fe5 DIFF: https://github.com/llvm/llvm-project/commit/c63522e6ba7782c335043893ae7cbd37eca24fe5.diff L

[clang-tools-extra] 29fc5e0 - [clang-tidy] Fixed a compile warning (NFC).

2022-02-07 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-02-07T14:56:27+01:00 New Revision: 29fc5e0245cb360387cb8daac52c13dbc390fafd URL: https://github.com/llvm/llvm-project/commit/29fc5e0245cb360387cb8daac52c13dbc390fafd DIFF: https://github.com/llvm/llvm-project/commit/29fc5e0245cb360387cb8daac52c13dbc390fafd.diff L

[clang] 83028ad - [clang][AST][ASTImporter] Set record to complete during import of its members.

2022-02-13 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-02-14T08:27:44+01:00 New Revision: 83028ad934d60b024b5b0272cb68523232715dab URL: https://github.com/llvm/llvm-project/commit/83028ad934d60b024b5b0272cb68523232715dab DIFF: https://github.com/llvm/llvm-project/commit/83028ad934d60b024b5b0272cb68523232715dab.diff L

[clang-tools-extra] 0e95921 - [clang-tidy] Improve check cert-dcl58-cpp.

2022-07-14 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-07-14T09:04:03+02:00 New Revision: 0e95921bc303a206cc6ae1c21ee90ec223bf9e78 URL: https://github.com/llvm/llvm-project/commit/0e95921bc303a206cc6ae1c21ee90ec223bf9e78 DIFF: https://github.com/llvm/llvm-project/commit/0e95921bc303a206cc6ae1c21ee90ec223bf9e78.diff L

[clang] 94ca2be - [clang][analyzer] Added partial wide character support to CStringChecker

2022-07-25 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-07-25T09:23:14+02:00 New Revision: 94ca2beccc595c89c37eb3e5215ac97c3d930c8f URL: https://github.com/llvm/llvm-project/commit/94ca2beccc595c89c37eb3e5215ac97c3d930c8f DIFF: https://github.com/llvm/llvm-project/commit/94ca2beccc595c89c37eb3e5215ac97c3d930c8f.diff L

[clang] acd80a2 - [clang][ASTImporter] Improved handling of functions with auto return type.

2022-07-25 Thread Balázs Kéri via cfe-commits
Author: Balázs Kéri Date: 2022-07-25T10:28:01+02:00 New Revision: acd80a29ae7dcffabcb41e8579ebf4f371f0ddd7 URL: https://github.com/llvm/llvm-project/commit/acd80a29ae7dcffabcb41e8579ebf4f371f0ddd7 DIFF: https://github.com/llvm/llvm-project/commit/acd80a29ae7dcffabcb41e8579ebf4f371f0ddd7.diff L

[clang] [analyzer] Fix false double free when including 3rd-party headers with overloaded delete operator as system headers (PR #85224)

2024-03-19 Thread Balázs Kéri via cfe-commits
@@ -1090,7 +1090,8 @@ static bool isStandardNewDelete(const FunctionDecl *FD) { // If the header for operator delete is not included, it's still defined // in an invalid source location. Check to make sure we don't crash. return !L.isValid() || - FD->getASTContext

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-19 Thread Balázs Kéri via cfe-commits
balazske wrote: > So, it seems removing them from `StdLibraryFunctionsChecker` is not out of > the question. We can leave them together with other stream functions, or we > could move them to `UnixAPIChecker`, which we have enabled downstream. > > I think the latter is a reasonable compromise

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-19 Thread Balázs Kéri via cfe-commits
balazske wrote: > @balazske Are you interested in refactoring the logic of > `StdLibraryFunctionsChecker` into an API that can be used by separate > checkers? I could try it. It would solve at least the (dependency) difficulties related to this checker. Probably the checker can remain and con

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-20 Thread Balázs Kéri via cfe-commits
@@ -1204,6 +1204,20 @@ void StreamChecker::evalGetdelim(const FnDescription *Desc, State->BindExpr(E.CE, C.getLocationContext(), RetVal); StateNotFailed = E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call)); +// The buffer size `*n` must

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-20 Thread Balázs Kéri via cfe-commits
@@ -1179,6 +1195,113 @@ void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +ProgramStateRef StreamChecker::ensureGetdelimBufferAndSizeCorrect( +SVal LinePtrPtrSVal, SVal SizePtrSVal, const Expr *LinePtrPtrExp

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-20 Thread Balázs Kéri via cfe-commits
@@ -1204,6 +1204,20 @@ void StreamChecker::evalGetdelim(const FnDescription *Desc, State->BindExpr(E.CE, C.getLocationContext(), RetVal); StateNotFailed = E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call)); +// The buffer size `*n` must

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-20 Thread Balázs Kéri via cfe-commits
@@ -1217,6 +1231,11 @@ void StreamChecker::evalGetdelim(const FnDescription *Desc, E.isStreamEof() ? ErrorFEof : ErrorFEof | ErrorFError; StateFailed = E.setStreamState( StateFailed, StreamState::getOpened(Desc, NewES, !NewES.isFEof())); + // On failure, the con

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-20 Thread Balázs Kéri via cfe-commits
@@ -1204,6 +1204,20 @@ void StreamChecker::evalGetdelim(const FnDescription *Desc, State->BindExpr(E.CE, C.getLocationContext(), RetVal); StateNotFailed = E.assumeBinOpNN(StateNotFailed, BO_GE, RetVal, E.getZeroVal(Call)); +// The buffer size `*n` must

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-21 Thread Balázs Kéri via cfe-commits
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void getline_null_file() { + char *buffer = NULL; + size_t n = 0; + getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be NULL}} +} + +void getdelim_null_file() { + ch

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-21 Thread Balázs Kéri via cfe-commits
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void getline_null_file() { + char *buffer = NULL; + size_t n = 0; + getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be NULL}} +} + +void getdelim_null_file() { + ch

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-21 Thread Balázs Kéri via cfe-commits
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void getline_null_file() { + char *buffer = NULL; + size_t n = 0; + getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be NULL}} +} + +void getdelim_null_file() { + ch

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-21 Thread Balázs Kéri via cfe-commits
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void getline_null_file() { + char *buffer = NULL; + size_t n = 0; + getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be NULL}} +} + +void getdelim_null_file() { + ch

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-21 Thread Balázs Kéri via cfe-commits
@@ -376,3 +377,122 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void getline_null_file() { + char *buffer = NULL; + size_t n = 0; + getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be NULL}} +} + +void getdelim_null_file() { + ch

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-22 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. I did not find more issues (at least in `StreamChecker` and its tests). But did not check in detail the `UnixAPIChecker` part and tests. https://github.com/llvm/llvm-project/pull/83027 ___ cfe-co

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-22 Thread Balázs Kéri via cfe-commits
@@ -376,3 +377,75 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void getline_null_file() { + char *buffer = NULL; + size_t n = 0; + getline(&buffer, &n, NULL); // expected-warning {{Stream pointer might be NULL}} +} + +void getdelim_null_file() { + cha

[clang] [clang][analyzer] Improve BlockInCriticalSectionsChecker (PR #80029)

2024-03-22 Thread Balázs Kéri via cfe-commits
balazske wrote: It looks like that this change causes crashes on many projects (curl, vim, postgres, others) in `RAIIMutexDescriptor::initIdentifierInfo`. https://github.com/llvm/llvm-project/pull/80029 ___ cfe-commits mailing list cfe-commits@lists.l

[clang] [clang][analyzer] Change modeling of `fseek` in StreamChecker. (PR #86919)

2024-03-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/86919 Until now function `fseek` returned nonzero on error, this is changed to -1 only. And it does not produce EOF error any more. This complies better with the POSIX standard. From b6c76404c2f0b0e960adcadd7f089ecc5

[clang] [clang][StaticAnalyzer] Adding getentropy to CStringChecker. (PR #83675)

2024-03-28 Thread Balázs Kéri via cfe-commits
@@ -2515,6 +2517,53 @@ void CStringChecker::evalSprintfCommon(CheckerContext &C, const CallEvent &Call, C.addTransition(State); } +void CStringChecker::evalGetentropy(CheckerContext &C, const CallEvent &Call) const { + DestinationArgExpr Buffer = {{Call.getArgExpr(0), 0}}

[clang] [clang][analyzer] Improve documentation of StreamChecker (NFC). (PR #83858)

2024-03-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske closed https://github.com/llvm/llvm-project/pull/83858 ___ 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 `fseek` in StreamChecker. (PR #86919)

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

[clang] [clang][analyzer] Add "pedantic" mode to StreamChecker. (PR #87322)

2024-04-02 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/87322 The checker may create failure branches for all stream write operations only if the new option "pedantic" is set to true. Result of the write operations is often not checked in typical code. If failure branches

[clang] [clang][analyzer] Add "pedantic" mode to StreamChecker. (PR #87322)

2024-04-02 Thread Balázs Kéri via cfe-commits
balazske wrote: > Unless you plan to add more heuristics, I'd prefer a more concrete option > name, like AssumeSuccessfulWrites=true. This would better describe it imo. I do not like totally the name "Pedantic", it could be "AssumeOftenUncheckedOperationsMayFail". I am not sure if this behavio

[clang] [clang][analyzer] Add note tags to alpha.unix.BlockInCriticalSection (PR #80029)

2024-02-07 Thread Balázs Kéri via cfe-commits
@@ -57,6 +61,12 @@ class BlockInCriticalSectionChecker : public Checker { const CallEvent &call, CheckerContext &C) const; + CritSectionMarker getCriticalSectionMarker(const CallEvent &Call, +

[clang] [clang][analyzer] Add note tags to alpha.unix.BlockInCriticalSection (PR #80029)

2024-02-08 Thread Balázs Kéri via cfe-commits
@@ -57,6 +61,12 @@ class BlockInCriticalSectionChecker : public Checker { const CallEvent &call, CheckerContext &C) const; + CritSectionMarker getCriticalSectionMarker(const CallEvent &Call, +

[clang] [clang][analyzer] Add missing stream related functions to StdLibraryFunctionsChecker. (PR #76979)

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

[clang] [clang][analyzer] Remove 'alpha.core.CallAndMessageUnInitRefArg' from documentation (NFC). (PR #81138)

2024-02-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/81138 This checker does not exist (any more?) but appeared in the documentation. No other references to CallAndMessageUnInitRefArg are found in the full clang code. From b9f0e178ab08286fda1c11e96e2ad46ab75ecf8b Mon S

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/80457 From 1f65abda712efce624c01ec99675c8261a8e6cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 31 Jan 2024 17:40:21 +0100 Subject: [PATCH] {clang][analyzer] Change default value of c

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-09 Thread Balázs Kéri via cfe-commits
balazske wrote: The change was evaluated on the following projects. "Lost reports" shows results that disappear if the `ModelPOSIX` option is changed to true. "New reports" shows the new results. Many of the new results come from the large number of modeled functions. The lost reports are more

[clang] [clang][analyzer] Reformat code of BoolAssignmentChecker (NFC). (PR #81461)

2024-02-12 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/81461 This is only a code reformatting and rename of variables to the newer format. From d1078be3394fc240de014f72116e18d6740b5773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 12 Feb 2

[clang] [clang][analyzer] Remove 'alpha.core.CallAndMessageUnInitRefArg' from documentation (NFC). (PR #81138)

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

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-13 Thread Balázs Kéri via cfe-commits
balazske wrote: The new appeared bug reports should be similar to the ones that were observed when `StdCLibraryFunctionsChecker` was made non-alpha (and probably were checked already one time) (because the option was turned on in those tests). A different solution can be to add a Linux-mode for

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-13 Thread Balázs Kéri via cfe-commits
balazske wrote: > * a [straightforward leak of a string returned by > `strdup()`](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=postgres_REL_13_0_modelposix_defaulton&newcheck=postgres_REL_13_0_modelposix_defaultoff&is-unique=on&diff-type=New&report-id=3467892&repo

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-13 Thread Balázs Kéri via cfe-commits
balazske wrote: Because the many cases with `fileno` I can agree to change the summary so we assume that it never fails. Probably an other checker may find a case if the passed file handle is invalid because it was not initialized, or the file was already closed (`StreamChecker` should find th

[clang] [clang][analyzer] Improve documentation of StreamChecker (NFC). (PR #83858)

2024-03-05 Thread Balázs Kéri via cfe-commits
@@ -3020,44 +3020,82 @@ Check for misuses of stream APIs. Check for misuses of stream APIs: ``fopen, fcl alpha.unix.Stream (C) " -Check stream handling functions: ``fopen, tmpfile, fclose, fread, fwrite, fseek, ftell, rewind, fgetpos,`` -``fsetpos, cleare

[clang] [clang][StaticAnalyzer] Adding getentropy to CStringChecker. (PR #83675)

2024-03-05 Thread Balázs Kéri via cfe-commits
balazske wrote: Currently it looks OK to add `getentropy` to this checker because it is a string related function in a way. Otherwise it looks like that many of the checks (for buffer access, and buffer invalidations) that are implemented in `CStringChecker` could be moved to `StdLibraryFuncti

[clang] [clang][analyzer] Fix StreamChecker `ftell` and `fgetpos` at indeterminate file position. (PR #84191)

2024-03-06 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/84191 These functions should not be allowed if the file position is indeterminate (they return the file position). This condition is now checked, and tests are improved to check it. From f5e2ba88eb79d778daf9d3e8f55a5

[clang] [clang][analyzer] Fix StreamChecker `ftell` and `fgetpos` at indeterminate file position. (PR #84191)

2024-03-07 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/84191 From dbaf3348510582c013254ed48b69663b42816be0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 6 Mar 2024 16:01:01 +0100 Subject: [PATCH] [clang][analyzer] Fix StreamChecker `ftell`

[clang] [clang][analyzer] Fix StreamChecker `ftell` and `fgetpos` at indeterminate file position. (PR #84191)

2024-03-07 Thread Balázs Kéri via cfe-commits
@@ -880,6 +883,24 @@ void StreamChecker::preReadWrite(const FnDescription *Desc, } } +void StreamChecker::preWrite(const FnDescription *Desc, const CallEvent &Call, balazske wrote: The `CallDescriptionMap` was uncomfortable to handle because too many `std:

[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

2024-03-07 Thread Balázs Kéri via cfe-commits
@@ -603,6 +611,8 @@ void ArrayBoundCheckerV2::performCheck(const Expr *E, CheckerContext &C) const { auto [WithinUpperBound, ExceedsUpperBound] = compareValueToThreshold(State, ByteOffset, *KnownSize, SVB); +bool AssumedNonNegative = SUR.assumedNonNegative();

[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

2024-03-07 Thread Balázs Kéri via cfe-commits
@@ -603,6 +611,8 @@ void ArrayBoundCheckerV2::performCheck(const Expr *E, CheckerContext &C) const { auto [WithinUpperBound, ExceedsUpperBound] = compareValueToThreshold(State, ByteOffset, *KnownSize, SVB); +bool AssumedNonNegative = SUR.assumedNonNegative();

[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

2024-03-07 Thread Balázs Kéri via cfe-commits
balazske wrote: The change looks correct, but it would be more accurate if 3 different index error cases would be possible, index is too small (negative), too large, or can be both too small and too large. https://github.com/llvm/llvm-project/pull/84201

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-07 Thread Balázs Kéri via cfe-commits
balazske wrote: `StreamChecker` still does not check for all possible NULL pointer errors. At `fread` and `fwrite` for example there is no check for NULL buffer pointer. The reason is that these are checked in `StdLibraryFunctionsChecker`. Probably it would be better to add the checks for prec

[clang] [clang][analyzer] Fix StreamChecker `ftell` and `fgetpos` at indeterminate file position. (PR #84191)

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

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
balazske wrote: Additionally, the checked preconditions look not exact. For example the POSIX documentation for `getdelim` says: "If *n is non-zero, the application shall ensure that *lineptr either points to an object of size at least *n bytes, or is a null pointer." This means `*lineptr` can

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

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

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske commented: This functionality could be added to this checker, but to `StdLibraryFunctionsChecker` too, and probably will be added at a time (summary of `getdelim` is not accurate now in that checker). The same bug condition is checked by two different checkers in th

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -234,6 +235,9 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/83027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +ProgramStateRef +StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr, +CheckerContext &C, P

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +ProgramStateRef +StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr, +CheckerContext &C, P

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -510,6 +517,14 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/83027 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +ProgramStateRef +StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr, +CheckerContext &C, P

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -1158,6 +1173,118 @@ void StreamChecker::evalUngetc(const FnDescription *Desc, const CallEvent &Call, C.addTransition(StateFailed); } +ProgramStateRef +StreamChecker::ensurePtrNotNull(SVal PtrVal, const Expr *PtrExpr, +CheckerContext &C, P

[clang] [clang][analyzer] Model more getline/getdelim pre and postconditions (PR #83027)

2024-03-08 Thread Balázs Kéri via cfe-commits
balazske wrote: I want to avoid that some functions have null pointer checks in `StreamChecker`, some not. If this change is merged then it would be good to add null pointer checks to other functions like `fread` and `fwrite`. (Until now only the NULL stream pointer was checked.) https://gith

[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

2024-03-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske approved this pull request. I am not totally sure but this looks correct with the new variable names and there are some tests for the new case. https://github.com/llvm/llvm-project/pull/84201 ___ cfe-commits mailing list cf

[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

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

[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

2024-03-08 Thread Balázs Kéri via cfe-commits
@@ -83,6 +83,8 @@ class StateUpdateReporter { AssumedUpperBound = UpperBoundVal; } + bool assumedNonNegative() { return AssumedNonNegative; } balazske wrote: This should be called `getAssumedNonNegative` or `hasAssumedNonNegative` (but the naming rule

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void test_fscanf_eof() { + FILE *F1 = tmpfile(); + if (!F1) +return; + + int a; + unsigned b; + int ret = fscanf(F1, "%d %u", &a, &b); + char c = fgetc(F1); // expected-warning {{Rea

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

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

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
https://github.com/balazske requested changes to this pull request. I would like better if the new tests that are invalidation-related are moved to file **stream-invalidate.c** (this was added in the recent commit). https://github.com/llvm/llvm-project/pull/82476 ___

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void test_fscanf_eof() { balazske wrote: Has this test a purpose that is different from test `error_fscanf` in **stream_error.c**? https://github.com/llvm/llvm-project/pull

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void test_fscanf_eof() { + FILE *F1 = tmpfile(); + if (!F1) +return; + + int a; + unsigned b; + int ret = fscanf(F1, "%d %u", &a, &b); + char c = fgetc(F1); // expected-warning {{Rea

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void test_fscanf_eof() { + FILE *F1 = tmpfile(); + if (!F1) +return; + + int a; + unsigned b; + int ret = fscanf(F1, "%d %u", &a, &b); + char c = fgetc(F1); // expected-warning {{Rea

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -339,3 +363,138 @@ void fflush_on_open_failed_stream(void) { } fclose(F); } + +void test_fscanf_eof() { + FILE *F1 = tmpfile(); + if (!F1) +return; + + int a; + unsigned b; + int ret = fscanf(F1, "%d %u", &a, &b); + char c = fgetc(F1); // expected-warning {{Rea

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

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

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -65,12 +65,24 @@ void check_fseek(void) { fclose(fp); } +void check_fseeko(void) { balazske wrote: If we have these null pointer tests for all functions, `vfprintf` and `vfscanf` could be added too. https://github.com/llvm/llvm-project/pull/82476 _

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
https://github.com/balazske commented: I have only small observations. https://github.com/llvm/llvm-project/pull/82476 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

2024-02-26 Thread Balázs Kéri via cfe-commits
@@ -5,7 +5,7 @@ // suppressed. #pragma clang system_header -typedef struct __sFILE { balazske wrote: This change looks not needed. https://github.com/llvm/llvm-project/pull/82476 ___ cfe-commits mailing list cfe-co

[clang] [clang][analyzer] StreamChecker: Model getc, vfscanf, putc, vfprintf (PR #82476)

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

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/83288 If a stream operation fails the position can become "indeterminate". This may cause warning from the checker at a later operation. The new note tag shows the place where the position becomes "indeterminate", th

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-28 Thread Balázs Kéri via cfe-commits
balazske wrote: Related to this, I want to change text "File position of the stream might be 'indeterminate'" to something better, or maybe only remove the `'` characters from it. https://github.com/llvm/llvm-project/pull/83288 ___ cfe-commits mailin

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/83288 From f5aeb6e97e73d317d55189c656c31a84757f9636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 28 Feb 2024 17:51:29 +0100 Subject: [PATCH] [clang][analyzer] Add StreamChecker note ta

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-28 Thread Balázs Kéri via cfe-commits
balazske wrote: fixed formatting errors https://github.com/llvm/llvm-project/pull/83288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-28 Thread Balázs Kéri via cfe-commits
balazske wrote: Behavior of `fileno` is already changed in #81842. I was thinking about that > separate long-term solution in last comment that it is already existing functionality (in StreamChecker and other invalid pointer checkers). Should we run again the checks (only modeling of `fileno`

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-29 Thread Balázs Kéri via cfe-commits
@@ -218,87 +218,6 @@ inline void assertStreamStateOpened(const StreamState *SS) { assert(SS->isOpened() && "Stream is expected to be opened"); } -struct StreamOperationEvaluator { balazske wrote: There should be something that is used from `StreamChecker`

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-29 Thread Balázs Kéri via cfe-commits
@@ -313,6 +232,9 @@ class StreamChecker : public Checkerhttps://github.com/llvm/llvm-project/pull/83288 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][analyzer] Add StreamChecker note tags for "indeterminate stream position". (PR #83288)

2024-02-29 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/83288 From f5aeb6e97e73d317d55189c656c31a84757f9636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 28 Feb 2024 17:51:29 +0100 Subject: [PATCH 1/2] [clang][analyzer] Add StreamChecker not

[clang] [clang][analyzer] Change default value of checker option in unix.StdCLibraryFunctions. (PR #80457)

2024-02-29 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/80457 From 1f65abda712efce624c01ec99675c8261a8e6cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 31 Jan 2024 17:40:21 +0100 Subject: [PATCH 1/2] {clang][analyzer] Change default value

<    1   2   3   4   5   6   7   8   9   >