[clang] [CXX Safe Buffer] Update the documentation for unsafe_buffer_usage attribute (PR #135087)

2025-04-09 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/135087 >From edbdfa66b45be76014f003f8e2d6f2d2871ea253 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 9 Apr 2025 14:31:06 -0700 Subject: [PATCH] Update the documentation for the unsafe_buffer_usage attri

[clang] [CXX Safe Buffer] Update the documentation for unsafe_buffer_usage attribute (PR #135087)

2025-04-10 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak closed https://github.com/llvm/llvm-project/pull/135087 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Add absl::{Span,string_view} to UnsafeBufferUsage analysis (PR #127698)

2025-04-01 Thread Malavika Samak via cfe-commits
@@ -891,7 +891,9 @@ AST_MATCHER(CallExpr, hasUnsafeSnprintfBuffer) { // Pattern 1: static StringRef SizedObjs[] = {"span", "array", "vector", - "basic_string_view", "basic_string"}; + "basic_string_view", "b

[clang] [-Wunsafe-buffer-usage] Fix false positives for constant cases (PR #92432)

2025-04-30 Thread Malavika Samak via cfe-commits
malavikasamak wrote: Identifying safe operations on String literals has already landed as part of: https://github.com/llvm/llvm-project/pull/115552. However, identifying safe pointer arithmetic is not yet available. So, maybe we should revisit this PR once again. https://github.com/llvm/llvm

[clang] [-Wunsafe-buffer-usage] Fix a bug that wrongly assumed CXXMethodDecl always has an identifier (PR #137248)

2025-04-24 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak approved this pull request. https://github.com/llvm/llvm-project/pull/137248 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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

2025-02-19 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/112284 >From bf1f0b88c26cef3fd7eab40341558e1742c62321 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Fri, 11 Oct 2024 12:24:58 -0700 Subject: [PATCH] [Wunsafe-buffer-usage] False positives for & expression i

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

2025-02-19 Thread Malavika Samak via cfe-commits
malavikasamak wrote: @dtarditi FYI. https://github.com/llvm/llvm-project/pull/112284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-21 Thread Malavika Samak via cfe-commits
@@ -245,3 +243,40 @@ struct AggregateViaDefaultInit { void testAggregateViaDefaultInit() { AggregateViaDefaultInit A; }; + +struct A { + int arr[2]; + + [[clang::unsafe_buffer_usage]] + int *ptr; +}; + +namespace std{ + template class span { + + T *elements; + + pu

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

2025-02-21 Thread Malavika Samak via cfe-commits
@@ -462,8 +462,25 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { // bug if (ArrIdx.isNonNegative() && ArrIdx.getLimitedValue() < limit) return true; - } - return false; + } else if (const auto *BE = dyn_cast(IndexExpr)) { +if (BE->getOpcode() !=

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

2025-02-21 Thread Malavika Samak via cfe-commits
@@ -462,8 +462,25 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { // bug if (ArrIdx.isNonNegative() && ArrIdx.getLimitedValue() < limit) return true; - } - return false; + } else if (const auto *BE = dyn_cast(IndexExpr)) { +if (BE->getOpcode() !=

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-21 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/125671 >From 821a4b46705375bb34e207d406d8d7e9a2818f85 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Fri, 31 Jan 2025 13:19:46 +0530 Subject: [PATCH 1/2] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-21 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak deleted https://github.com/llvm/llvm-project/pull/125671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-24 Thread Malavika Samak via cfe-commits
@@ -245,3 +243,40 @@ struct AggregateViaDefaultInit { void testAggregateViaDefaultInit() { AggregateViaDefaultInit A; }; + +struct A { + int arr[2]; + + [[clang::unsafe_buffer_usage]] + int *ptr; +}; + +namespace std{ + template class span { + + T *elements; + + pu

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-24 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/125671 >From 821a4b46705375bb34e207d406d8d7e9a2818f85 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Fri, 31 Jan 2025 13:19:46 +0530 Subject: [PATCH 1/3] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning

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

2025-02-24 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak closed https://github.com/llvm/llvm-project/pull/112284 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-24 Thread Malavika Samak via cfe-commits
@@ -245,3 +243,56 @@ struct AggregateViaDefaultInit { void testAggregateViaDefaultInit() { AggregateViaDefaultInit A; }; + +struct A { + int arr[2]; + + [[clang::unsafe_buffer_usage]] + int *ptr; +}; + +namespace std{ + template class span { + + T *elements; + + pu

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

2025-02-24 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/112284 >From bf1f0b88c26cef3fd7eab40341558e1742c62321 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Fri, 11 Oct 2024 12:24:58 -0700 Subject: [PATCH 1/2] [Wunsafe-buffer-usage] False positives for & expressio

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

2025-02-24 Thread Malavika Samak via cfe-commits
@@ -462,8 +462,25 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) { // bug if (ArrIdx.isNonNegative() && ArrIdx.getLimitedValue() < limit) return true; - } - return false; + } else if (const auto *BE = dyn_cast(IndexExpr)) { malavikasa

[clang] [Wunsafe-buffer-usage] Turn off unsafe-buffer warning for methods annotated with clang::unsafe_buffer_usage attribute (PR #125671)

2025-02-25 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak closed https://github.com/llvm/llvm-project/pull/125671 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix false positives for string literals (PR #115554)

2025-04-03 Thread Malavika Samak via cfe-commits
malavikasamak wrote: I think we can close this PR, since we already merged this as part of https://github.com/llvm/llvm-project/pull/115552 https://github.com/llvm/llvm-project/pull/115554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https:

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-25 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 01/11] Place holder message for sizeof operator in loops.

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-25 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak closed https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (PR #140113)

2025-05-15 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/140113 >From c6d8a58a8468fb3e6bcbe7d5935e2aa033745d99 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Thu, 15 May 2025 10:46:01 -0700 Subject: [PATCH 1/2] [-Wunsafe-buffer-usage] Fix false warnings when const

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/8] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
@@ -219,6 +219,11 @@ Changes in existing checks tolerating fix-it breaking compilation when functions is used as pointers to avoid matching usage of functions within the current compilation unit. +- Improved :doc: `bugprone-sizeof-expression malavikasamak

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
@@ -164,6 +164,53 @@ int Test2(MyConstChar* A) { return sum; } +struct A { + int array[10]; +}; + +struct B { + struct A a; +}; + +void loop_access_elements(int num, struct B b) { +struct A arr[10]; +char buf[20]; + +// CHECK-MESSAGES: :[[@LINE+1]]:5: warning:

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/7] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
@@ -353,6 +367,19 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { diag(E->getBeginLoc(), "suspicious usage of 'sizeof(char*)'; do you mean 'strlen'?") << E->getSourceRange(); + } else if (const auto *E = Result.Nodes.getNode

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak edited https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-18 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/7] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-21 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/9] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-24 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 01/11] Place holder message for sizeof operator in loops.

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-24 Thread Malavika Samak via cfe-commits
@@ -353,6 +372,22 @@ void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) { diag(E->getBeginLoc(), "suspicious usage of 'sizeof(char*)'; do you mean 'strlen'?") << E->getSourceRange(); + } else if (const auto *E = Result.Nodes.getNode

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-17 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/6] Place holder message for sizeof operator in loops. --

[clang-tools-extra] [WIP] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-09 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/3] Place holder message for sizeof operator in loops. --

[clang] [-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (PR #140113)

2025-05-16 Thread Malavika Samak via cfe-commits
malavikasamak wrote: CC @dtarditi https://github.com/llvm/llvm-project/pull/140113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (PR #140113)

2025-05-16 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak closed https://github.com/llvm/llvm-project/pull/140113 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [-Wunsafe-buffer-usage] Fix false warnings when const sized array is safely accessed (array [idx %const]) (PR #140113)

2025-05-15 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak created https://github.com/llvm/llvm-project/pull/140113 The -Wunsafe-buffer-usage analysis currently warns when a const sized array is safely accessed, with an index that is bound by the remainder operator. The false alarm is now suppressed. Example: int cir

[clang-tools-extra] [WIP] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-06 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak created https://github.com/llvm/llvm-project/pull/143205 None >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH] Place holder message for sizeof operator in loops.

[clang-tools-extra] [WIP] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-06 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/2] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] [WIP] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-10 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/4] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] [WIP] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak updated https://github.com/llvm/llvm-project/pull/143205 >From 52e4413ea1e701dfe0b24cf957a26bb72732f066 Mon Sep 17 00:00:00 2001 From: MalavikaSamak Date: Wed, 21 May 2025 16:06:44 -0700 Subject: [PATCH 1/5] Place holder message for sizeof operator in loops. --

[clang] [clang-tools-extra] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak edited https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak edited https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak edited https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak edited https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
@@ -561,6 +561,20 @@ Improvements to Clang's diagnostics Improvements to Clang's time-trace -- +Improvements to clang-tidy +-- + +New checks +^^ + +Changes in existing checks +^^ +-Improved

[clang] [clang-tools-extra] [clang-tidy] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-12 Thread Malavika Samak via cfe-commits
https://github.com/malavikasamak edited https://github.com/llvm/llvm-project/pull/143205 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang-tools-extra] [WIP] Warn about misuse of sizeof operator in loops. (PR #143205)

2025-06-11 Thread Malavika Samak via cfe-commits
@@ -316,3 +316,11 @@ Options When `true`, the check will warn on pointer arithmetic where the element count is obtained from a division with ``sizeof(...)``, e.g., ``Ptr + Bytes / sizeof(*T)``. Default is `true`. + +.. option:: WarnOnSizeOfInLoopTermination + + When

<    1   2