[clang] Add unique_ptr <T[]> accesses to -Wunsafe-buffer-usage (PR #156773)
Jan Korous via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 17 11:48:09 PDT 2025
================
@@ -2606,6 +2606,19 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
#endif
}
+ void handleUnsafeUniquePtrArrayAccess(const DynTypedNode &Node,
+ bool IsRelatedToDecl,
+ ASTContext &Ctx) override {
+ SourceLocation Loc;
+ std::string Message;
+
+ Loc = Node.get<Stmt>()->getBeginLoc();
+ Message = "Direct operator[] access on std::unique_ptr<T[]> is unsafe "
----------------
jkorous-apple wrote:
This message doesn't look that much different from what we put for `warn_unsafe_buffer_usage_unique_ptr_array_access` in `clang/include/clang/Basic/DiagnosticSemaKinds.td`.
Maybe we could keep just one of them?
https://github.com/llvm/llvm-project/pull/156773
More information about the cfe-commits
mailing list