[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-09-05 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko closed https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-09-03 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: @steakhal @NagyDonat Thank you both for the thorough review and valuable feedback! I've addressed the latest comments with the following commits: - Test formatting improvement: 6dd767160bef315748488ef3e0598d2847b40c47 - Documentation improvement: 196abdb3e4bd4eced37933dd

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-09-03 Thread Ivan Murashko via cfe-commits
@@ -3145,27 +3144,71 @@ static bool isSmartOwningPtrType(QualType QT) { if (!ND) return false; -// Accept both std and custom smart pointer implementations for broader -// coverage -return isSmartOwningPtrName(ND->getName()); +// For broader coverage

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: Thank you very much, @NagyDonat, for the review and useful comments - especially the code pointers, which I used in 7c6ffa87d87fed8097558a9b79e9fb321903239b. I believe that I have addressed all comments, and the code is ready for the next review. Beyond resolving the comme

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: > Moreover I thought about the approach that you currently emphasize "owning" > in every name and comment where you speak about smart pointers. As this is > not a distinguishing feature of these functions (you never interact with > non-owning smart pointers) and these func

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,242 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1104,54 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,225 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart owning pointer name +static bool isSmartOwningPtrName(StringRef Name) { + return Name =

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,232 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix \ +// RUN: -analyzer-checker=unix.Malloc + +#include "Inputs/system-header-simulator-fo

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-30 Thread Ivan Murashko via cfe-commits
@@ -3194,7 +3480,6 @@ void MallocChecker::checkEscapeOnReturn(const ReturnStmt *S, if (!Sym) // If we are returning a field of the allocated struct or an array element, // the callee could still free the memory. -// TODO: This logic should be a part of generic sy

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-29 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: Thanks for the review, @NagyDonat. I am still working on addressing the "duplicates the traversal logic" comment and will return to the other comments right after the commit that addresses this major part of the refactoring. Overall, I plan to address all comments by the en

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-28 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,242 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-28 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,242 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-28 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,242 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-28 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,242 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-28 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1104,54 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: Thanks for the feedback! I've already added the commit hashes to my responses above. I'll avoid force-pushes going forward and use merges to preserve the commit history. https://github.com/llvm/llvm-project/pull/152751 ___ cfe-co

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3124,240 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Helper function to check if a name is a recognized smart pointer name +static bool isSmartPtrName(StringRef Name) { + return Name == "unique_ptr

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-22 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1104,54 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-18 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: Hi @steakhal — I believe I have addressed all your comments: I added a test with multiple memory-owning arguments, fixed the misuse of `addTransition` by returning early when post-handlers exist, and simplified `checkPostCall` to about ten lines of code. All tests pass. Whe

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-16 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,80 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
@@ -3068,12 +3125,235 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Allowlist of owning smart pointers we want to recognize. +// Start with unique_ptr and shared_ptr. (intentionally exclude weak_ptr) +static bool

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/15] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/15] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/15] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/14] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/13] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/13] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/13] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/12] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: > clang-tidy: False positive potential memory leak warning with aggregate > initialization of unique_ptr members #153300 > > I am sorry, looks like I found another regression: > > ... > > With your patch applied `raw` leak is not reported, however current CSA > > finds it

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-15 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/12] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1098,47 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/11] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3110,195 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Allowlist of owning smart pointers we want to recognize. +// Start with unique_ptr and shared_ptr. (intentionally exclude weak_ptr) +static bool

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3110,195 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Allowlist of owning smart pointers we want to recognize. +// Start with unique_ptr and shared_ptr. (intentionally exclude weak_ptr) +static bool

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 01/10] [clang-analyzer] Add regression test for PR60896 ---

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-11 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3110,195 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Allowlist of owning smart pointers we want to recognize. +// Start with unique_ptr and shared_ptr. (intentionally exclude weak_ptr) +static bool

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,80 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/9] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/8] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/7] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1098,47 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1098,47 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/6] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3107,24 +3111,13 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } -static QualType canonicalStrip(QualType QT) { - return QT.getCanonicalType().getUnqualifiedType(); -} - -static bool isInStdNamespace(const DeclCont

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -52,6 +52,7 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" + ivanmurashko wrote: Applied https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3111,174 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +// Use isWithinStdNamespace from CheckerHelpers.h instead of custom +// implementation + +// Allowlist of owning smart pointers we want to recognize

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/6] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,37 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus,unix -verify %s +// expected-no-diagnostics + ivanmurashko wrote: Done https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mail

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,44 @@ +// RUN: %clang_analyze_cc1 -verify -analyzer-output=text %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=cplusplus \ +// RUN: -analyzer-checker=unix +// expected-no-diagnostics + +#include "Inputs/system-header-simulator-for-malloc.h" + +/

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/5] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} ivanmurashko wrote: Replac

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -52,6 +52,9 @@ #include "clang/AST/DeclTemplate.h" #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" +#include "clang/AST/TemplateBase.h" +#include "clang/AST/Type.h" + ivanmurashko wrote: Applied the patch https://github.com/llvm/llvm-project/pul

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/5] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -1096,6 +1100,41 @@ class StopTrackingCallback final : public SymbolVisitor { return true; } }; + +/// EscapeTrackedCallback - A SymbolVisitor that marks allocated symbols as +/// escaped. +/// +/// This visitor is used to suppress false positive leak reports when smar

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
@@ -3068,11 +3107,217 @@ void MallocChecker::checkDeadSymbols(SymbolReaper &SymReaper, C.addTransition(state->set(RS), N); } +static QualType canonicalStrip(QualType QT) { + return QT.getCanonicalType().getUnqualifiedType(); +} + +static bool isInStdNamespace(const DeclCon

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/5] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-08 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/152751 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-08 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/152751 >From 7d1c7000c7482f8d1ec1593b77a8f4a9456082ac Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 8 Aug 2025 10:25:26 +0100 Subject: [PATCH 1/4] [clang-analyzer] Add regression test for PR60896 --- .

[clang] [clang-analyzer] MallocChecker – Fix false positive leak for smart pointers in temporary objects (PR #152751)

2025-08-08 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko created https://github.com/llvm/llvm-project/pull/152751 ## Summary Fixes [PR60896](https://github.com/llvm/llvm-project/issues/60896) — false positive leak reports when `std::unique_ptr` or `std::shared_ptr` are members of a temporary object passed **by value**

[clang] [C++20][Modules] Fix non-determinism in serialized AST (PR #110131)

2024-09-26 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko approved this pull request. @eaeltsin confirmed that the commit fixes an issue introduced earlier by [#109167](https://github.com/llvm/llvm-project/pull/109167). The fix LGTM https://github.com/llvm/llvm-project/pull/110131 ___

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-21 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko closed https://github.com/llvm/llvm-project/pull/91645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-20 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: Friendly ping @sam-mccall , @jansvoboda11 , could you look at the diff. It fixes a critical issue for anyone who wants to use Clang modules with file remapping, for instance at clangd. https://github.com/llvm/llvm-project/pull/91645

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-13 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: Hi @sam-mccall, The patch touches some fairly old code that hasn't been modified for a long time. You are one of the few people who worked on it recently, around two years ago. I would appreciate any comments and a review of the suggested patch. https://github.com/llvm/ll

[clang] [Modules] Enable MS Windows test for implicit-module-no-timestamp.cpp (PR #91738)

2024-05-11 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko closed https://github.com/llvm/llvm-project/pull/91738 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Modules] Enable MS Windows test for implicit-module-no-timestamp.cpp (PR #91738)

2024-05-11 Thread Ivan Murashko via cfe-commits
ivanmurashko wrote: @dmpolukhin , the test was successfully passed on MS Windows. There is the corresponding record from the build log ``` _bk;t=1715380522596PASS: Clang :: Modules/implicit-module-no-timestamp.cpp (12618 of 20053) ``` https://github.com/llvm/llvm-project/pull/91738 _

[clang] [Modules] Enable MS Windows test for implicit-module-no-timestamp.cpp (PR #91738)

2024-05-11 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/91738 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Modules] Enable MS Windows test for implicit-module-no-timestamp.cpp (PR #91738)

2024-05-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko created https://github.com/llvm/llvm-project/pull/91738 There is a followup commit for #90319. The windows test was disabled at that commit but it should pass on MS Windows and it would be good to have it enabled. >From 6e5bd93173a8515749115f45c993ddf472437c79 M

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/91645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/91645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-10 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko edited https://github.com/llvm/llvm-project/pull/91645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Processing real directories added as virtual ones (PR #91645)

2024-05-09 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko created https://github.com/llvm/llvm-project/pull/91645 The `FileManager` might create a virtual directory that can be used later as a search path. If the added record is a real directory that is present on a disk, we might encounter a false cache miss and add t

[clang] [Modules] Process include files changes with -fmodules-validate-input-files-content and -fno-pch-timestamp options (PR #90319)

2024-05-01 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko closed https://github.com/llvm/llvm-project/pull/90319 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Modules] Process include files changes with -fmodules-validate-input-files-content and -fno-pch-timestamp options (PR #90319)

2024-04-30 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/90319 >From 71796a80e15b6700fec23fbec70635aae455b188 Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 26 Apr 2024 22:45:26 +0100 Subject: [PATCH] [Modules] Process include files changes with -fmodules-vali

[clang] [Modules] Process include files changes with -fmodules-validate-input-files-content and -fno-pch-timestamp options (PR #90319)

2024-04-30 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,34 @@ +// UNSUPPORTED: system-windows +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: cd %t +// +// RUN: cp a1.h a.h +// RUN: %clang -fmodules -fmodules-validate-input-files-content -Xclang -fno-pch-timestamp -fimplicit-modules -fmodule-map-file=module.modulemap

[clang] [Modules] Process include files changes with -fmodules-validate-input-files-content and -fno-pch-timestamp options (PR #90319)

2024-04-30 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/90319 >From 3c36295b5f0f1e011e11d57c5ec4e685cb917cab Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 26 Apr 2024 22:45:26 +0100 Subject: [PATCH] [Modules] Process include files changes with -fmodules-vali

[clang] [Modules] Process include files changes with -fmodules-validate-input-files-content and -fno-pch-timestamp options (PR #90319)

2024-04-30 Thread Ivan Murashko via cfe-commits
@@ -0,0 +1,34 @@ +// UNSUPPORTED: system-windows +// RUN: rm -rf %t +// RUN: split-file %s %t +// RUN: cd %t +// +// RUN: cp a1.h a.h +// RUN: %clang -fmodules -fmodules-validate-input-files-content -Xclang -fno-pch-timestamp -fimplicit-modules -fmodule-map-file=module.modulemap

[clang] [Modules] Process include files changes with -fmodules-validate-input-files-content and -fno-pch-timestamp options (PR #90319)

2024-04-30 Thread Ivan Murashko via cfe-commits
https://github.com/ivanmurashko updated https://github.com/llvm/llvm-project/pull/90319 >From 48a019ead18d3e8aeb5d10d0301c2567ef1c5cd7 Mon Sep 17 00:00:00 2001 From: Ivan Murashko Date: Fri, 26 Apr 2024 22:45:26 +0100 Subject: [PATCH] [Modules] Process include files changes with -fmodules-vali

  1   2   >