[clang] [-Wunsafe-buffer-usage] Add a subgroup `-Wunsafe-buffer-usage-in-container` (PR #75665)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 14:26:00 PST 2023


https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/75665

Add a sub diagnostic group under `-Wunsafe-buffer-usage` controlled by `-Wunsafe-buffer-usage-in-container`.  The subgroup will include warnings on misuses of `std::span`, `std::vector`, and `std::array`.

>From 9501ffef8db9bf52879a815ad99033f17635796b Mon Sep 17 00:00:00 2001
From: ziqingluo-90 <ziqing at udel.edu>
Date: Fri, 15 Dec 2023 14:04:57 -0800
Subject: [PATCH] [-Wunsafe-buffer-usage] Add a subgroup
 `-Wunsafe-buffer-usage-in-container`

Add a sub diagnostic group under `-Wunsafe-buffer-usage` controlled by
`-Wunsafe-buffer-usage-in-container`.  The subgroup will include
warnings on misuses of `std::span`, `std::vector`, and `std::array`.
---
 clang/include/clang/Basic/DiagnosticGroups.td | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td
index 80b5680b94f6ca..7cf347e92d9972 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1488,4 +1488,5 @@ def DXILValidation : DiagGroup<"dxil-validation">;
 def ReadOnlyPlacementChecks : DiagGroup<"read-only-types">;
 
 // Warnings and fixes to support the "safe buffers" programming model.
-def UnsafeBufferUsage : DiagGroup<"unsafe-buffer-usage">;
+def UnsafeBufferUsageInContainer : DiagGroup<"unsafe-buffer-usage-in-container">;
+def UnsafeBufferUsage : DiagGroup<"unsafe-buffer-usage", [UnsafeBufferUsageInContainer]>;



More information about the cfe-commits mailing list