[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-24 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/96501 The checker could report false positives if pointer arithmetic was done on pointers to non-array data before pointer subtraction. Another problem is fixed that could cause false positive if members of the same

[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-26 Thread Balázs Kéri via cfe-commits
balazske wrote: These results look correct according to the checker, but I am not sure if such results are useful or really invalid: https://codechecker-demo.eastus.cloudapp.azure.com/Default/reports?run=vim_v8.2.1920_pointersub1&is-unique=on&diff-type=New&checker-name=alpha.core.PointerSub In t

[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-26 Thread Balázs Kéri via cfe-commits
balazske wrote: The warning message may be still misleading if the LHS or RHS "arrays" are non-array variables. Is it better to improve the messages in this case (or detect if `offsetof` can be used and include it in the message)? https://github.com/llvm/llvm-project/pull/96501 ___

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-27 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/96295 From 0c57ad1ca36a841dff700eb98f878475e0243b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Fri, 21 Jun 2024 12:13:02 +0200 Subject: [PATCH 1/3] [clang][analyzer] Improve documentation

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

2024-06-27 Thread Balázs Kéri via cfe-commits
balazske wrote: I fixed a test that contained the entire option help description. I think this is not needed, removed it and only included the first line of the description. https://github.com/llvm/llvm-project/pull/96295 ___ cfe-commits mailing list

[clang] [clang][analyzer] Improve documentation of checker 'cplusplus.Move' (NFC) (PR #96295)

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

[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-28 Thread Balázs Kéri via cfe-commits
balazske wrote: If the array bounds checker does the same job then the array bounds check it is not needed in this checker. Specially if it makes no difference if the indexing is used at pointer subtraction. https://github.com/llvm/llvm-project/pull/96501 __

[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-06-28 Thread Balázs Kéri via cfe-commits
balazske wrote: Even protobuf contains this type of code: https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=protobuf_v3.13.0_pointersub1&is-unique=on&diff-type=New&checker-name=alpha.core.PointerSub&report-id=5545776&report-hash=1bcd310fbaeccbcc13645b9b277239a2&report-f

[clang] [clang][analyzer] MmapWriteExecChecker improvements (PR #97078)

2024-06-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/97078 Read the 'mmap' flags from macro values and use a better test for the error situation. From 1f04ce794a3aefc0f5622a9dea0a92a1e2b50be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue

[clang] [clang][analyzer] Fix documentation of checker 'StackAddrAsyncEscape' (NFC) (PR #108586)

2024-09-13 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/108586 The checker was indicated as a 'C' language checker but is only applicable to 'ObjC' code. From 620a17fca9e6c011099e223cb965cd4bcc8f413a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date

[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

2024-10-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/111846 From a9e1790691e01892f7e1b17523cd43421445f3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 10 Oct 2024 16:28:50 +0200 Subject: [PATCH 1/3] [clang][analyzer] PointerSubChecker sh

[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical type (PR #111846)

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

[clang] [clang][analyzer] Improve test and documentation in cstring NotNullTerminated checker (PR #112019)

2024-10-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/112019 CStringChecker has a sub-checker alpha.unix.cstring.NotNullTerminated which checks for invalid objects passed to string functions. The checker and its name are not exact and more functions could be checked, th

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-04 Thread Balázs Kéri via cfe-commits
balazske wrote: I was thinking about using `check::Location` in this checker. The real problem is when the fixed address is used (to store or load), not if it is assigned to a pointer. (Or a fixed address becomes escaped.) Or both cases (with the current checks) can be used, but then multiple

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-04 Thread Balázs Kéri via cfe-commits
balazske wrote: When `check::Location` is used it looks better to extend the `DereferenceChecker` with this new check that looks simple to add to it (it uses `check::Bind` too, probably this finds the cases when location does not work). Only difficulty is that this is a non-fatal error. https

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-04 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/110977 From 36d99fc59b675737ce952087b7a71ec6e4b579a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 30 Sep 2024 16:51:35 +0200 Subject: [PATCH 1/3] [clang][analyzer] Check initialization

[clang] [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'security.PointerSub' (PR #107596)

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

[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/110458 If a fixed value is assigned to a pointer variable, the checker did emit a warning. If the pointer variable is assigned to another pointer variable, this resulted in another warning. The checker now emits warn

[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-10-02 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/110458 From eb03076eca550ea53143bc753639f22bbb7caa35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 30 Sep 2024 09:19:52 +0200 Subject: [PATCH 1/2] [clang][analyzer] Less redundant warni

[clang] [clang][analyzer] Improve test and documentation in cstring NotNullTerminated checker (PR #112019)

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

[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)

2024-10-17 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/112688 After a previous fix and commit 30a9cac error handling in function 'importTemplateParameterDefaultArgument' was not correct because std::move was removed from return of an Error object and this caused crash "E

[clang] [clang][AST] CXXRecords in anony namespace from diff TUs shouldn't be equivalent (PR #112534)

2024-10-18 Thread Balázs Kéri via cfe-commits
balazske wrote: The fix looks acceptable, but a test is needed. The test code in the bug report can be used somehow in at the AST merge LIT tests or in the `ASTImporterTest`. https://github.com/llvm/llvm-project/pull/112534 ___ cfe-commits mailing lis

[clang] [clang][ASTImporter] Fix of unchecked Error object (PR #112688)

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

[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical value (PR #111846)

2024-10-10 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/111846 Pointer values casted to integer (non-pointer) type should be able to be subtracted as usual. From a9e1790691e01892f7e1b17523cd43421445f3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= D

[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical value (PR #111846)

2024-10-10 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/111846 From a9e1790691e01892f7e1b17523cd43421445f3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 10 Oct 2024 16:28:50 +0200 Subject: [PATCH 1/2] [clang][analyzer] PointerSubChecker sh

[clang] [clang][analyzer] PointerSubChecker should not warn on pointers converted to numerical value (PR #111846)

2024-10-10 Thread Balázs Kéri via cfe-commits
@@ -61,6 +61,10 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator *B, if (LR->getSymbolicBase() || RR->getSymbolicBase()) return; + if (!B->getLHS()->getType()->isPointerType() || + !B->getRHS()->getType()->isPointerType()) +return;

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-10-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/113899 From 9cf4203652f06a140288a5c1ab6d14bcc3612380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 28 Oct 2024 11:23:55 +0100 Subject: [PATCH 1/2] [clang][analyzer] Bring checker 'alph

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-10-28 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/113899 I have tested it on the usual amount of C and C++ projects, no results were found. This checker is only for very rare cases, I do not know if it is really useful but it is there and can be moved out of alpha.

[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)

2024-11-11 Thread Balázs Kéri via cfe-commits
balazske wrote: Currently one of the tests fail, the problem is fixed if #115518 is applied. https://github.com/llvm/llvm-project/pull/115734 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-co

[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)

2024-11-11 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/115734 The fix applies to a case that occurs when the AST contains a friend template that is contained within another template and this (outer) template has specialization. (See the added test code in the commit.) Th

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-11 Thread Balázs Kéri via cfe-commits
balazske wrote: I had another simple fix when the cache is used only if `IgnoreTemplateParmDepth` is false which is the often used case. During one structural equivalence comparison `IgnoreTemplateParmDepth` does not change, just one set of the cached values (for `IgnoreTemplateParmDepth`) is

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-12 Thread Balázs Kéri via cfe-commits
balazske wrote: It is a realistic requirement that new similar parameters are added, I had already an (experimental) fix where this is needed. Still I like better the solution with separate caches because efficiency reasons (`IgnoreTemplateParmDepth = true` is rarely used, not at all for C cod

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

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

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-08 Thread Balázs Kéri via cfe-commits
balazske wrote: Another possible solution: Use two `NonEquivalentDecls` sets, one for `IgnoreTemplateParmDepth` = true and one for false. This may use less memory (no rarely used third value in the key) but requires more code changes. Probably use these two caches only in `ASTImporter` where t

[clang] [clang][AST] Add 'IgnoreTemplateParmDepth' to structural equivalence cache (PR #115518)

2024-11-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/115518 Structural equivalence check uses a cache to store already found non-equivalent values. This cache can be reused for calls (ASTImporter does this). Value of "IgnoreTemplateParmDepth" can have an effect on the

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-11-12 Thread Balázs Kéri via cfe-commits
@@ -53,3 +53,7 @@ struct TestNotNullTerm { strlen((char *)&x); // expected-warning{{Argument to string length function is not a null-terminated string}} } }; + +void test_notcstring_tempobject() { + strlen((char[]){'a', 0}); // expected-warning{{Argument to string lengt

[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)

2024-11-12 Thread Balázs Kéri via cfe-commits
@@ -6120,6 +6119,19 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) { // see ASTTests test ImportExistingFriendClassTemplateDef. continue; } +// When importing a friend, it is possible that multiple declarations

[clang] [clang][analyzer] FixedAddressChecker: no warning if system macro is used (PR #108993)

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

[clang] [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'security.PointerSub' (PR #107596)

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

[clang] [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'core.PointerSub' (PR #107596)

2024-09-27 Thread Balázs Kéri via cfe-commits
balazske wrote: I moved the checker now into package `security`. The main reason is that the checker should not be turned on by default because use of such low-level features may be valid in some projects. The checker is not absolutely security-related but there was no better place for it (`o

[clang] [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'core.PointerSub' (PR #107596)

2024-09-27 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/107596 From be6fbcad245bd16b013e9337270e0ade23a5b9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Fri, 6 Sep 2024 16:30:59 +0200 Subject: [PATCH 1/2] [clang][analyzer] Move 'alpha.core.Poin

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-03 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/110977 None From 36d99fc59b675737ce952087b7a71ec6e4b579a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 30 Sep 2024 16:51:35 +0200 Subject: [PATCH] [clang][analyzer] Check initializati

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-03 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/110977 From 36d99fc59b675737ce952087b7a71ec6e4b579a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 30 Sep 2024 16:51:35 +0200 Subject: [PATCH 1/2] [clang][analyzer] Check initialization

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-03 Thread Balázs Kéri via cfe-commits
@@ -23,38 +25,35 @@ using namespace ento; namespace { class FixedAddressChecker - : public Checker< check::PreStmt > { +: public Checker, check::PreStmt, + check::PreStmt> { const BugType BT{this, "Use fixed address"}; + void checkUseOfFixedAddre

[clang] [clang][analyzer] Check initialization and argument passing in FixedAddressChecker (PR #110977)

2024-10-03 Thread Balázs Kéri via cfe-commits
balazske wrote: I changed the variable names and now `PreCall` is used so it should work with other call cases. Tests are not added for all cases like default values. I plan to split the tests from **ptr-arith.c** into separate C and C++ files (the checker is planned to be moved into the `opti

[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

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

[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)

2024-10-17 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/112688 From 0694ea396728fe34f031fa1102460f56da4d3822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Thu, 17 Oct 2024 12:03:55 +0200 Subject: [PATCH 1/2] [clang][ASTImporter] Fix of unchecked

[clang] [clang][ASTImporter] Fix of unchecked Error object (PR #112688)

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

[clang] [clang][ASTImporter] Fix of unchecked Error object (NFC) (PR #112688)

2024-10-17 Thread Balázs Kéri via cfe-commits
balazske wrote: I do not want now to check what is exactly happening, the case is a bit interesting. Normally `return Err` should work and is used at other functions too. And why did not a similar crash happen at the unit tests? Probably it is caused by different compilation on other platform

[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)

2024-11-15 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/115734 From eca94b1ff721d8ec857a5fdee8b358ce22d210aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 11 Nov 2024 16:53:59 +0100 Subject: [PATCH 1/2] [clang][ASTImporter] Allow import of s

[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)

2024-11-15 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/115734 From eca94b1ff721d8ec857a5fdee8b358ce22d210aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 11 Nov 2024 16:53:59 +0100 Subject: [PATCH] [clang][ASTImporter] Allow import of simil

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

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

[clang] [clang][analyzer] FixedAddressChecker: no warning if system macro is used (PR #108993)

2024-09-17 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/108993 None From c13a4d7ed344209359ddb838b2688805ceb06304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Tue, 17 Sep 2024 17:33:34 +0200 Subject: [PATCH] [clang][analyzer] FixedAddressChecke

[clang] [clang][ASTImporter] Allow import of similar friend template with different depth (PR #115734)

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

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-11-25 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/113899 From 9cf4203652f06a140288a5c1ab6d14bcc3612380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 28 Oct 2024 11:23:55 +0100 Subject: [PATCH 1/3] [clang][analyzer] Bring checker 'alph

[clang] [clang][analyzer] Bring checker 'alpha.unix.cstring.NotNullTerminated' out of alpha (PR #113899)

2024-11-25 Thread Balázs Kéri via cfe-commits
balazske wrote: I have added a FIXME to the place where no warning should appear. Additionally a new test file is added where only this checker is turned on (not the full `cstring`). https://github.com/llvm/llvm-project/pull/113899 ___ cfe-commits ma

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-03 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/118466 `ASTImporterLookupTable` did use the `getPrimaryContext` function to get the declaration context of the inserted items. This is problematic because the primary context can change during import of AST items, mo

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-03 Thread Balázs Kéri via cfe-commits
@@ -3165,6 +3165,7 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { if (Error Err = ImportImplicitMethods(DCXX, FoundCXX)) return std::move(Err); } +return FoundDef; balazske wrote: I

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-03 Thread Balázs Kéri via cfe-commits
balazske wrote: I have tested the change with CTU analysis and did not see significant difference, and no new crashes (in these tests there was one known instance of unreachable at ASTImporterLookupTable.cpp:121 that is fixed by the change). There were some differences in the found reports, pr

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

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

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

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

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
@@ -10181,6 +10184,151 @@ TEST_P(ImportTemplateParmDeclDefaultValue, FromD, FromDInherited); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportIntoReopenedNamespaceNoMatch1) { + const char *ToCode = + R"( + namespace a { + } + namespace a { +

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
@@ -10181,6 +10184,151 @@ TEST_P(ImportTemplateParmDeclDefaultValue, FromD, FromDInherited); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportIntoReopenedNamespaceNoMatch1) { + const char *ToCode = + R"( + namespace a { + } + namespace a { +

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
@@ -6082,6 +6084,7 @@ TEST_P(ASTImporterLookupTableTest, LookupSearchesInTheWholeRedeclChain) { auto Res = LT.lookup(N1, Name); ASSERT_EQ(Res.size(), 1u); EXPECT_EQ(*Res.begin(), A); + EXPECT_TRUE(LT.lookup(N2, Name).empty()); balazske wrote: Yes, prev

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
@@ -10181,6 +10184,151 @@ TEST_P(ImportTemplateParmDeclDefaultValue, FromD, FromDInherited); } +TEST_P(ASTImporterOptionSpecificTestBase, ImportIntoReopenedNamespaceNoMatch1) { + const char *ToCode = + R"( + namespace a { + } + namespace a { +

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/118466 From e97972c18fd88129bb868b1bfc880f7fdb8e8c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Fri, 29 Nov 2024 18:00:04 +0100 Subject: [PATCH 1/2] [clang][ASTImporter] Not using primary

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
@@ -3165,6 +3165,7 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl *D) { if (Error Err = ImportImplicitMethods(DCXX, FoundCXX)) return std::move(Err); } +return FoundDef; balazske wrote: Th

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
balazske wrote: > Does this have any affect on other redeclarable `DeclContext`s such as class > forward declarations? In the code of `DeclContext::getPrimaryContext` it is visible that it has only effect on declarations and it depends on whether it has a definition or not (except namespace a

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

2024-12-18 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/118466 From e97972c18fd88129bb868b1bfc880f7fdb8e8c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Fri, 29 Nov 2024 18:00:04 +0100 Subject: [PATCH] [clang][ASTImporter] Not using primary con

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

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

[clang] [clang][analyzer] Split NullDereferenceChecker into a modeling and checker part (PR #122139)

2025-01-09 Thread Balázs Kéri via cfe-commits
@@ -155,22 +155,27 @@ static bool isDeclRefExprToReference(const Expr *E) { void DereferenceChecker::reportBug(DerefKind K, ProgramStateRef State, const Stmt *S, CheckerContext &C) const { + if (!CheckNullDereference) { +C.addSink(); ---

[clang] [clang][analyzer] Split NullDereferenceChecker into a modeling and checker part (PR #122139)

2025-01-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/122139 From 135839a993f1cad32d65d21c6aeaef6f074a1997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 8 Jan 2025 17:22:10 +0100 Subject: [PATCH 1/2] [clang][analyzer] Split NullDereference

[clang] [clang][analyzer] Split NullDereferenceChecker into a modeling and checker part (PR #122139)

2025-01-08 Thread Balázs Kéri via cfe-commits
balazske wrote: Our plan is to add a new check for dereference of fixed address (like `(*0x111) = 1`). This is similar to the current `FixedAddressChecker` but has less false positives (if a fixed value is used as placeholder but never dereferenced). Additionally the existing checks for undefi

[clang] [clang][analyzer] Split NullDereferenceChecker into a modeling and checker part (PR #122139)

2025-01-08 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/122139 The checker currently reports beneath the null dereference dereferences of undefined value and of label addresses. If we want to add more kinds of invalid dereferences (or split the existing functionality) it

[clang] [clang][analyzer] Split NullDereferenceChecker into a modeling and checker part (PR #122139)

2025-01-08 Thread Balázs Kéri via cfe-commits
balazske wrote: I wanted to avoid change the current behavior of `core.NullDereference`. But it is better to move the option of address space suppression into the modeling part, I guess this option should be used for all types of invalid dereferences. https://github.com/llvm/llvm-project/pull/

[clang] [clang][analyzer] Split NullDereferenceChecker into modeling and reporting (PR #122139)

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

[clang] [clang][ASTImporter] Fix possible crash at import of function template (PR #124273)

2025-01-24 Thread Balázs Kéri via cfe-commits
balazske wrote: If this case is not handled, the following `setDescribedFunctionTemplate` will run into an assertion. The case happens in the test code. What exactly happens is that because of the `__get_first_arg` mismatch a field `basic_string::_M_allocated_capacity` is missing from `basic_s

[clang] [clang][ASTImporter][test] Add test for importing explicit object parameter (PR #124305)

2025-01-24 Thread Balázs Kéri via cfe-commits
@@ -3441,13 +3441,33 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportParmVarDecl) { ASSERT_TRUE(FromVar); ASSERT_TRUE(FromVar->hasUninstantiatedDefaultArg()); ASSERT_TRUE(FromVar->getUninstantiatedDefaultArg()); + ASSERT_FALSE(FromVar->isExplicitObjectParameter());

[clang] [clang][ASTImporter] Fix possible crash at import of function template (PR #124273)

2025-01-24 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/124273 During import of a function template at specific conditions an assertion "TemplateOrSpecialization.isNull()" can be triggered. This can happen when the new AST is already incompatible after import failures. Prob

[clang] [clang][ASTImporter] Import source location of explicit object parameter instead of copying it (PR #124305)

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

[clang] [clang][ASTImporter] Fix possible crash at import of function template (PR #124273)

2025-01-27 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/124273 From 4109a5166b544c33af333505883b414db7c0c14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Wed, 22 Jan 2025 17:55:51 +0100 Subject: [PATCH 1/3] fix test --- clang/lib/AST/ASTImport

[clang] [clang][ASTImporter] Fix possible crash at import of function template (PR #124273)

2025-01-27 Thread Balázs Kéri via cfe-commits
balazske wrote: It seems that this test is not reducible any further (except very small changes) (to get the original crash). I could remove only few lines. https://github.com/llvm/llvm-project/pull/124273 ___ cfe-commits mailing list cfe-commits@list

[clang] [clang][ASTImporter] Fix possible crash at import of function template (PR #124273)

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

[clang] [clang][ASTImporter] Not using primary context in lookup table (PR #118466)

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

[clang] [clang][ASTImporter] Fix unused variable warning (NFC) (PR #122686)

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

[clang] [clang][ASTImporter] Fix unused variable warning (NFC) (PR #122686)

2025-01-13 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/122686 None From 1b11dfc89cc81c1d48479cdcc7a4f5936d4ddb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 13 Jan 2025 11:33:40 +0100 Subject: [PATCH] [clang][ASTImporter] Fix unused vari

[clang] [clang][analyzer] Split NullDereferenceChecker into modeling and reporting (PR #122139)

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

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-14 Thread Balázs Kéri via cfe-commits
https://github.com/balazske created https://github.com/llvm/llvm-project/pull/127191 None From 1f2ad6d5ce6f11fb031ec2175527f56ea86761ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 3 Feb 2025 15:35:31 +0100 Subject: [PATCH] [clang][analyzer] Add checker 'alpha

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-14 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/127191 From 1f2ad6d5ce6f11fb031ec2175527f56ea86761ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 3 Feb 2025 15:35:31 +0100 Subject: [PATCH 1/2] [clang][analyzer] Add checker 'alpha.c

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-14 Thread Balázs Kéri via cfe-commits
balazske wrote: It may cause confusion that "NullDereference" checker checks not only null dereference but undefined pointer and label address too. Probably these checks (specially label address) can be moved into this checker. (Or add the new check to NullDereference without a new checker?)

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-14 Thread Balázs Kéri via cfe-commits
balazske wrote: The checker is alpha because there are known problems with it which I plan to fix later. A problem is with the bugpath messages where a constant pointer was assumed to be a null pointer but after this checker (or even before it?) this is not true. https://github.com/llvm/llvm-p

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-17 Thread Balázs Kéri via cfe-commits
@@ -129,6 +129,8 @@ The ``SuppressAddressSpaces`` option suppresses warnings for null dereferences of all pointers with address spaces. You can disable this behavior with the option ``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``. +Value of this option is

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-17 Thread Balázs Kéri via cfe-commits
@@ -1,7 +1,163 @@ // RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -verify %s -// expected-no-diagnostics -void foo(void) { +extern void __assert_fail (__const char *__assertion, __const char *__file, +unsigned int __line, __const char *__function) + __attri

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-17 Thread Balázs Kéri via cfe-commits
@@ -1,6 +1,6 @@ // NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued. -// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,alpha.core,osx.cocoa.AtSync -Wno-strict-prototypes -Wno-pointer-to-int-cast -verif

[clang] [analyzer] Delay the checker constructions after parsing (PR #127409)

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

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-17 Thread Balázs Kéri via cfe-commits
@@ -155,30 +162,47 @@ static bool isDeclRefExprToReference(const Expr *E) { void DereferenceChecker::reportBug(DerefKind K, ProgramStateRef State, const Stmt *S, CheckerContext &C) const { - if (!CheckNullDereference) { -C.addSink(); -

[clang] [analyzer] Delay the checker constructions after parsing (PR #127409)

2025-02-17 Thread Balázs Kéri via cfe-commits
@@ -73,6 +73,23 @@ Nullability getNullabilityAnnotation(QualType Type); /// returned. std::optional tryExpandAsInteger(StringRef Macro, const Preprocessor &PP); +class CachedMacroValue { balazske wrote: What is the advantage of using this instead of just `std

[clang] [analyzer] Delay the checker constructions after parsing (PR #127409)

2025-02-17 Thread Balázs Kéri via cfe-commits
@@ -40,17 +40,28 @@ enum class OpenVariant { OpenAt }; +static CachedMacroValue getCreateFlagValue(const ASTContext &Ctx, + const Preprocessor &PP) { + CachedMacroValue MacroVal("O_CREAT", PP); + if (MacroVal.hasValue()) +retur

[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-21 Thread Balázs Kéri via cfe-commits
https://github.com/balazske updated https://github.com/llvm/llvm-project/pull/127191 From 1f2ad6d5ce6f11fb031ec2175527f56ea86761ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= Date: Mon, 3 Feb 2025 15:35:31 +0100 Subject: [PATCH 1/5] [clang][analyzer] Add checker 'alpha.c

[clang] [clang][ASTImporter] Fix AST import if anonymous namespaces are merged (PR #128735)

2025-02-26 Thread Balázs Kéri via cfe-commits
balazske wrote: I meant that I did not verify where a namespace declaration is allowed, if it is allowed with another declaration as parent (which is not a `LinkageSpecDecl` and not `NamespaceDecl` and not `TranslationUnitDecl`). It looks likely that no other parent is possible. https://githu

<    3   4   5   6   7   8   9   >