[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > The current patch actually WILL work with it ONLY enabled on the line inside > of the function, which I think is much more intuitive. Ooo whoa this is awesome!! https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
@@ -202,6 +202,43 @@ class SemaPPCallbacks : public PPCallbacks { break; } } + void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, +diag::Severity Mapping, StringRef Str) override { +// If one of the analysis-based diagnostics

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: So from the user's perspective we're checking the flag twice: once at the `}` to see if we need to ramp up the analysis, then again at the diagnostic location to see if the diagnostic should be discarded. The warning will only be emitted if it's enabled at

[clang] Control analysis-based diagnostics with #pragma (PR #136323)

2025-04-18 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/136323 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-03-06 Thread Artem Dergachev via cfe-commits
Carlos =?utf-8?q?Gálvez?= , Carlos =?utf-8?q?Gálvez?= Message-ID: In-Reply-To: haoNoQ wrote: The static analyzer handles this pretty well already. I haven't heard of any problems in this area. I think it makes sense to use the same logic by default in other tools unless you do have specific

[clang] [analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (PR #126596)

2025-02-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Should we try to avoid calling the *value* uninitialized? Technically you initialize variables (or memory), not values. In the static analyzer terminology in particular, it's somewhat important that values are seen as immutable data that's temporarily associated with mutable memo

[clang] [analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (PR #126596)

2025-02-18 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: We could also go with something like "uninitialized or inaccessible memory" so that to technically cover the OOB case without triggering an immediate visceral reaction to buffer overruns. But it'll probably still be net-negative in confusion compared to a simple "uninitialized".

[clang] [analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (PR #126596)

2025-02-13 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: So when it comes to the ArrayBoundChecker, the checker that checks that every access is within bounds, I think that its underlying "model" should be enabled by default, so that to proactively terminate execution paths on which uninitialized accesses happen. It should probably eve

[clang] [analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (PR #126596)

2025-02-13 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Yes, right, this is more of a side effect of how we do things, not quite the intended behavior. In particular, if you write something out of bounds first, we will no longer report it as an uninitialized read, even though it's still an out-of-bounds read: https://godbolt.org/z/PYa

[clang] [analyzer] Update the undefined assignment checker diagnostics to not use the term 'garbage' (PR #126596)

2025-02-10 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Welcome!! I completely agree that the message sounds a bit too much like "your code is garbage" and that's not very nice. Here's a tangent suggestion to get a better wording out of this. You can exploit the fact that the static analyzer usually catches undefined values _very ea

[clang] [clang] Add steakhal to the Clang Static Analyzer maintainers (PR #114991)

2024-11-12 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. I wholeheartedly support this. I agree with everything you said here. Right now you're much more of a maintainer than me. https://github.com/llvm/llvm-project/pull/114991 ___ cfe-commits mailing li

[clang] [webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (PR #114897)

2024-11-04 Thread Artem Dergachev via cfe-commits
@@ -45,32 +52,119 @@ class UncountedLambdaCapturesChecker bool shouldVisitTemplateInstantiations() const { return true; } bool shouldVisitImplicitCode() const { return false; } - bool VisitLambdaExpr(LambdaExpr *L) { -Checker->visitLambdaExpr(L); +

[clang] [webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (PR #114897)

2024-11-04 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: The attribute gets some action! Nice!! I noticed that currently the attribute's documentation doesn't say it can be placed on lambdas. But it doesn't look like it's actively rejected either. So it might be a good idea to update the documentation as part of

[clang] [webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (PR #114897)

2024-11-04 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/114897 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [webkit.UncountedLambdaCapturesChecker] Ignore trivial functions and [[clang::noescape]]. (PR #114897)

2024-11-04 Thread Artem Dergachev via cfe-commits
@@ -45,32 +52,119 @@ class UncountedLambdaCapturesChecker bool shouldVisitTemplateInstantiations() const { return true; } bool shouldVisitImplicitCode() const { return false; } - bool VisitLambdaExpr(LambdaExpr *L) { -Checker->visitLambdaExpr(L); +

[clang] [Webkit Checkers] Introduce a Webkit checker for memory unsafe casts (PR #114606)

2024-11-01 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: Nice nice nice!! https://github.com/llvm/llvm-project/pull/114606 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Webkit Checkers] Introduce a Webkit checker for memory unsafe casts (PR #114606)

2024-11-01 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/114606 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Webkit Checkers] Introduce a Webkit checker for memory unsafe casts (PR #114606)

2024-11-01 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,86 @@ +//===- MemoryUnsafeCastChecker.cpp -*- C++ -*-==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-22 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > a function that returns a pointer and takes a reference (or a pointer) to a > length variable Yes, this one should be easy to catch. Both values will be `SymbolConjured` pointing to the same function call expression / program point. (The out-parameter value may also be `Symbol

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-22 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-22 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-10-22 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: No worries! I've just seen folks independently rediscover some of your work so I wanted them to see if they want to deduplicate the efforts. https://github.com/llvm/llvm-project/pull/91991 ___ cfe-commits mailing list [email protected]

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-10-21 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Please look at the dates. https://github.com/llvm/llvm-project/pull/91991 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-10-21 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: I did. The latest comment is https://github.com/llvm/llvm-project/pull/91991#discussion_r1643433741 https://github.com/llvm/llvm-project/pull/91991 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/ma

[clang] [-Wunsafe-buffer-usage] Fix false negatives of missing 2-param span ctors in constructor initializers (PR #113226)

2024-10-21 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: This overlaps with #91991 which should probably be landed in its entirety. (It looks like it's about attributes but in fact it isn't. It's about finding *all* gadgets in all those new places.) I think that patch was almost ready and it was a matter of considering my fix in https

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-20 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-20 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-20 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,76 @@ +// RUN: %clang %s -std=c++20 -Xclang -verify --analyze \ +// RUN: -Xclang -analyzer-checker=core,alpha.cplusplus.BoundsInformation \ +// RUN: -Xclang -analyzer-checker=debug.ExprInspection haoNoQ wrote: `ExprInspection` is probably unnecessa

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-20 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,199 @@ +//== BoundsInformationChecker.cpp - bounds information checker --*- C++ -*--==// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Ap

[clang] [clang][analyzer][doc] Update Clang SA www docs index.html (PR #112833)

2024-10-20 Thread Artem Dergachev via cfe-commits
@@ -69,48 +69,7 @@ Clang Static Analyzer -The Clang Static Analyzer is a source code analysis tool that finds bugs in -C, C++, and Objective-C programs. - -Currently it can be run either from the command - line or if you use macOS then within Xcode. When -invoked from the co

[clang] [analyzer] Add alpha.cplusplus.BoundsInformation checker (PR #112784)

2024-10-18 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: > but not to replace it And it doesn't necessarily need it in the first place! I think it's most likely going to be useful as a standalone checker even when you never needed `-Wunsafe-buffer-usage`. It's a bit coding-convention-y: roughly on the same level of "speculative" as t

[clang] [WIP][Wunsafe-buffer-usage] False positives for & expression indexing constant size array (arr[anything & 0]) (PR #112284)

2024-10-16 Thread Artem Dergachev via cfe-commits
@@ -427,6 +427,48 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { //- e. g. "Try harder to find a NamedDecl to point at in the note." //already duplicated // - call both from Sema and from here + std::function + SafeMaskedAccess; + unsigned int

[clang] [-Wunsafe-buffer-usage] Add user documentation. (PR #111624)

2024-10-16 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ closed https://github.com/llvm/llvm-project/pull/111624 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Emit a warning if pointer returned by vector::data and array::data is cast to larger type (PR #111910)

2024-10-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/111910 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Add user documentation. (PR #111624)

2024-10-10 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ updated https://github.com/llvm/llvm-project/pull/111624 >From b5c9082e36efcc7be2cabc73c985749f2fd41725 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Tue, 8 Oct 2024 20:24:00 -0700 Subject: [PATCH 1/3] [-Wunsafe-buffer-usage] Add user documentation. --- clang/

[clang] isUncountedPtr should take QualType as an argument. (PR #110213)

2024-10-09 Thread Artem Dergachev via cfe-commits
@@ -190,11 +190,7 @@ class UncountedLocalVarsChecker if (shouldSkipVarDecl(V)) return; -const auto *ArgType = V->getType().getTypePtr(); -if (!ArgType) haoNoQ wrote: Fair enough! https://github.com/llvm/llvm-project/pull/110213

[clang] isUncountedPtr should take QualType as an argument. (PR #110213)

2024-10-09 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. https://github.com/llvm/llvm-project/pull/110213 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Add the support for trivial CXXInheritedCtorInitExpr. (PR #111198)

2024-10-09 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Yes makes sense! I've no idea why this is a special case anyway. https://github.com/llvm/llvm-project/pull/98 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-b

[clang] [alpha.webkit.UncountedCallArgsChecker] Skip std::forward in tryToFindPtrOrigin. (PR #111222)

2024-10-09 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha LGTM! https://github.com/llvm/llvm-project/pull/111222 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Add user documentation. (PR #111624)

2024-10-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ updated https://github.com/llvm/llvm-project/pull/111624 >From b5c9082e36efcc7be2cabc73c985749f2fd41725 Mon Sep 17 00:00:00 2001 From: Artem Dergachev Date: Tue, 8 Oct 2024 20:24:00 -0700 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Add user documentation. --- clang/

[clang] [-Wunsafe-buffer-usage] Add user documentation. (PR #111624)

2024-10-08 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ created https://github.com/llvm/llvm-project/pull/111624 This is an attempt to finally land the documentation that I initially wrote in https://reviews.llvm.org/D136811 - which doubled as RFC - and I sincerely apologize for not doing this sooner. I've rewritten most

[clang] isUncountedPtr should take QualType as an argument. (PR #110213)

2024-10-01 Thread Artem Dergachev via cfe-commits
@@ -190,11 +190,7 @@ class UncountedLocalVarsChecker if (shouldSkipVarDecl(V)) return; -const auto *ArgType = V->getType().getTypePtr(); -if (!ArgType) haoNoQ wrote: Some of these null checks may still be necessary (with `QualType.isNull()`)

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -1771,6 +1771,10 @@ def UncountedLambdaCapturesChecker : Checker<"UncountedLambdaCapturesChecker">, let ParentPackage = WebKitAlpha in { +def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">, + HelpText<"Check for no unchecked member variables.">, +

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,53 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.NoUncheckedPtrMemberChecker -verify %s + +#include "mock-types.h" +#include "mock-system-header.h" haoNoQ wrote: Do you need to include this one everywhere? Isn't it just a tiny test to

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -134,10 +137,10 @@ class NoUncountedMemberChecker Os << " in "; printQuotedQualifiedName(Os, ClassCXXRD); Os << " is a " - << (isa(MemberType) ? "raw pointer" : "reference") - << " to ref-countable type "; + << (isa(MemberType) ? "raw pointer" :

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -146,13 +149,67 @@ class NoUncountedMemberChecker BR->emitReport(std::move(Report)); haoNoQ wrote: `setDeclWithIssue()` goes into a different PR right? https://github.com/llvm/llvm-project/pull/108352 ___ cfe-

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/108352 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -146,13 +149,67 @@ class NoUncountedMemberChecker BR->emitReport(std::move(Report)); } }; + +class NoUncountedMemberChecker final : public RawPtrRefMemberChecker { haoNoQ wrote: Yes this is a perfectly valid way to reuse code here! https://github.com

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM!! I've got nitpicks but none of them are substantial enough to block. We've figured out the ObjC thing offline right? https://github.com/llvm/llvm-project/pull/108352 ___ cfe-commits mailing l

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -53,48 +53,49 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const char *NameToMatch) { return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr; } -std::optional isRefCountable(const CXXRecordDecl* R) -{ +std::optional isSmartPtrCompatible(const CXXRecord

[clang] [alpha.webkit.UncountedCallArgsChecker] Use canonical type (PR #109393)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -102,12 +102,13 @@ class UncountedCallArgsChecker // if ((*P)->hasAttr()) // continue; -const auto *ArgType = (*P)->getType().getTypePtrOrNull(); -if (!ArgType) +QualType ArgType = (*P)->getType().getCanonicalType(); +const a

[clang] [alpha.webkit.UncountedCallArgsChecker] Use canonical type (PR #109393)

2024-09-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Ah classic! LGTM! https://github.com/llvm/llvm-project/pull/109393 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Use canonical type (PR #109393)

2024-09-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/109393 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] WebKit Checkers should set DeclWithIssue. (PR #109389)

2024-09-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM thank you so much! https://github.com/llvm/llvm-project/pull/109389 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] WebKit Checkers should set DeclWithIssue. (PR #109389)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -134,18 +135,25 @@ class UncountedLocalVarsChecker bool shouldVisitTemplateInstantiations() const { return true; } bool shouldVisitImplicitCode() const { return false; } + bool TraverseDecl(Decl *D) { +llvm::SaveAndRestore SavedDecl(DeclWithIssue);

[clang] WebKit Checkers should set DeclWithIssue. (PR #109389)

2024-09-25 Thread Artem Dergachev via cfe-commits
@@ -56,12 +62,16 @@ class UncountedCallArgsChecker bool TraverseClassTemplateDecl(ClassTemplateDecl *Decl) { if (isRefType(safeGetName(Decl))) return true; -return RecursiveASTVisitor::TraverseClassTemplateDecl( -Decl); +retur

[clang] WebKit Checkers should set DeclWithIssue. (PR #109389)

2024-09-25 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/109389 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (PR #109496)

2024-09-20 Thread Artem Dergachev via cfe-commits
@@ -784,12 +786,12 @@ AST_MATCHER_P(CallExpr, hasUnsafePrintfStringArg, return false; // possibly some user-defined printf function ASTContext &Ctx = Finder->getASTContext(); - QualType FristParmTy = FD->getParamDecl(0)->getType(); + QualType FirstParmTy = FD->getParam

[clang] [-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (PR #109496)

2024-09-20 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/109496 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix a bug and suppress libc warnings for C files (PR #109496)

2024-09-20 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/109496 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (PR #108656)

2024-09-17 Thread Artem Dergachev via cfe-commits
@@ -119,6 +119,11 @@ template ensureOnMainThread([this] { delete static_cast(this); }); +} else if constexpr (destructionThread == DestructionThread::MainRunLoop) { +auto deleteThis = [this] { haoNoQ

[clang] [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (PR #108656)

2024-09-17 Thread Artem Dergachev via cfe-commits
@@ -84,13 +84,22 @@ class DerefFuncDeleteExprVisitor E = E->IgnoreParenCasts(); if (auto *TempE = dyn_cast(E)) E = TempE->getSubExpr(); +E = E->IgnoreParenCasts(); +if (auto *Ref = dyn_cast(E)) { + if (auto *Decl = Ref->getDecl()) { +if (auto

[clang] [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (PR #108656)

2024-09-17 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/108656 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (PR #108656)

2024-09-17 Thread Artem Dergachev via cfe-commits
@@ -119,6 +119,11 @@ template ensureOnMainThread([this] { delete static_cast(this); }); +} else if constexpr (destructionThread == DestructionThread::MainRunLoop) { +auto deleteThis = [this] { haoNoQ

[clang] [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (PR #108656)

2024-09-17 Thread Artem Dergachev via cfe-commits
@@ -84,13 +84,22 @@ class DerefFuncDeleteExprVisitor E = E->IgnoreParenCasts(); if (auto *TempE = dyn_cast(E)) E = TempE->getSubExpr(); +E = E->IgnoreParenCasts(); +if (auto *Ref = dyn_cast(E)) { + if (auto *Decl = Ref->getDecl()) { +if (auto

[clang] [webkit.RefCntblBaseVirtualDtor] ThreadSafeRefCounted still generates warnings (PR #108656)

2024-09-17 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/108656 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Add support for Objective-C++ property access (PR #108669)

2024-09-17 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: I'm also somewhat terrified of returning C++ objects from ObjC methods by value, ever since I learned that when you call an ObjC method on a nil it returns a _zero-initialized_ object without calling a constructor on it. https://github.com/llvm/llvm-project/pull/108669 __

[clang] [alpha.webkit.UncountedCallArgsChecker] Add support for Objective-C++ property access (PR #108669)

2024-09-17 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Yeah sounds about right! The property syntax is confusing, I don't have enough expertise to confirm that `getResultExpr()` is the right solution so I think we should keep trying and incrementally figuring out what's going on. Setters proba

[clang] [WebKit Checkers] Allow "singleton" suffix to be camelCased. (PR #108257)

2024-09-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. LGTM! https://github.com/llvm/llvm-project/pull/108257 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (PR #108184)

2024-09-11 Thread Artem Dergachev via cfe-commits
@@ -143,6 +143,16 @@ bool isReturnValueRefCounted(const clang::FunctionDecl *F) { return false; } +std::optional isUncounted(const QualType T) { + if (auto *Subst = dyn_cast(T)) { +if (auto *Decl = Subst->getAssociatedDecl()) { + if (isRefType(safeGetName(Decl)))

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (PR #108184)

2024-09-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha ok LGTM! https://github.com/llvm/llvm-project/pull/108184 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (PR #108184)

2024-09-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/108184 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (PR #108184)

2024-09-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/108184 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (PR #108184)

2024-09-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/108184 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (PR #108184)

2024-09-11 Thread Artem Dergachev via cfe-commits
@@ -143,6 +143,16 @@ bool isReturnValueRefCounted(const clang::FunctionDecl *F) { return false; } +std::optional isUncounted(const clang::QualType T) { haoNoQ wrote: `clang::` is redundant because you're in `using namespace clang`. https://github.com/llvm

[clang] [WebKit Static Analyzer] Treat WTFReportBacktrace as a trivial function. (PR #108167)

2024-09-11 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. https://github.com/llvm/llvm-project/pull/108167 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)

2024-09-10 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. Aha great LGTM! https://github.com/llvm/llvm-project/pull/107676 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)

2024-09-10 Thread Artem Dergachev via cfe-commits
@@ -67,6 +68,48 @@ class DerefFuncDeleteExprVisitor const Decl *D = CE->getCalleeDecl(); if (D && D->hasBody()) return VisitBody(D->getBody()); +else { + auto name = safeGetName(D); + if (name == "ensureOnMainThread" || name == "ensureOnMainRunLoop")

[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)

2024-09-10 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/107676 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)

2024-09-10 Thread Artem Dergachev via cfe-commits
@@ -67,6 +68,15 @@ class DerefFuncDeleteExprVisitor const Decl *D = CE->getCalleeDecl(); if (D && D->hasBody()) return VisitBody(D->getBody()); +else if (!VisitLambdaBody) { + for (unsigned i = 0; i < CE->getNumArgs(); ++i) { +auto *Arg = CE->getA

[clang] [webkit.RefCntblBaseVirtualDtor] Make ThreadSafeRefCounted not generate warnings (PR #107676)

2024-09-10 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: Aha makes sense! Looks like you're putting no restrictions on what the opaque function is. This may cause some false negatives but it's probably ultimately ok, but it might be a good idea to confirm. https://github.com/llvm/llvm-project/pull/107676 ___

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-09-09 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: `-Wunsafe-buffer-usage` is theoretically possible to use in C but it involves a lot of `#pragma clang unsafe_buffer_usage` to annotate and encapsulate every unsafe buffer operation. So it's impractical but we aren't disabling it because that'd be an unnecessary restriction and it

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-29 Thread Artem Dergachev via cfe-commits
@@ -443,6 +443,426 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +AST_MATCHER_P(CallExpr, hasNumArgs, unsigned, Num) { + return Node.getNumArgs() == Num; +} + +namespace libc_func_matchers { +// Under `libc_func_matchers`, define a set of matche

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-29 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-29 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ approved this pull request. I think this is good to go, LGTM!! https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commit

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-28 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: #106439 https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Oh that's just a whitespace change. Would you like me to make a manual PR or were you looking into it anyway? https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list [email protected] https://lists.llvm.org

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: /cherry-pick 030ee841a9c9fbbd6e7c001e751737381da01f7b https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: /cherry-pick 3ddd7a6df3ef85cbfe3f5fc0294817638275d4df https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ milestoned https://github.com/llvm/llvm-project/pull/102226 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] Revert "[LinkerWrapper] Extend with usual pass options (#96704)" (PR #102226)

2024-08-27 Thread Artem Dergachev via cfe-commits
haoNoQ wrote: Yeah I think we really gotta cherry-pick this revert, because failing tests on release branches are somewhat scary (cf. https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA-release-branch/69/console). I don't know how it's usually done but let me try to push some buttons,

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -443,6 +448,368 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +namespace libc_fun_disjoint_inner_matchers { +// `libc_fun_disjoint_inner_matchers` covers a set of matchers that match +// disjoint node sets. They all take a `CoreName`, which

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -0,0 +1,101 @@ +// RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage \ +// RUN:-verify %s + +typedef struct {} FILE; +void memcpy(); +void __asan_memcpy(); +void strcpy(); +void strcpy_s(); +void wcscpy_s(); +unsigned strlen( const char* str ); +int fprintf(

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -443,6 +449,396 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +AST_MATCHER_P(CallExpr, hasNumArgs, unsigned, Num) { + return Node.getNumArgs() == Num; +} + +namespace libc_func_matchers { +// Under `libc_func_matchers`, define a set of matche

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ commented: Mostly LGTM! I don't have major concerns. https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -12383,6 +12383,13 @@ def warn_unsafe_buffer_operation : Warning< "%select{unsafe pointer operation|unsafe pointer arithmetic|" "unsafe buffer access|function introduces unsafe buffer manipulation|unsafe invocation of span::data}0">, InGroup, DefaultIgnore; +def warn_

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -12383,6 +12383,13 @@ def warn_unsafe_buffer_operation : Warning< "%select{unsafe pointer operation|unsafe pointer arithmetic|" "unsafe buffer access|function introduces unsafe buffer manipulation|unsafe invocation of span::data}0">, InGroup, DefaultIgnore; +def warn_

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -1025,6 +1421,92 @@ class DataInvocationGadget : public WarningGadget { DeclUseList getClaimedVarUseSites() const override { return {}; } }; +class UnsafeLibcFunctionCallGadget : public WarningGadget { + const CallExpr *const Call; + constexpr static const char *const T

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
@@ -443,6 +449,396 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { return false; } +AST_MATCHER_P(CallExpr, hasNumArgs, unsigned, Num) { + return Node.getNumArgs() == Num; +} + +namespace libc_func_matchers { +// Under `libc_func_matchers`, define a set of matche

[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-08-21 Thread Artem Dergachev via cfe-commits
https://github.com/haoNoQ edited https://github.com/llvm/llvm-project/pull/101583 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

  1   2   3   4   5   6   7   8   9   10   >