Skip to content

Commit 800d393

Browse files
committed
Update AnalysisBasedWarnings.cpp
1 parent 11fc596 commit 800d393

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,6 +2606,19 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26062606
#endif
26072607
}
26082608

2609+
void handleUnsafeUniquePtrArrayAccess(const DynTypedNode &Node,
2610+
bool IsRelatedToDecl,
2611+
ASTContext &Ctx) override {
2612+
SourceLocation Loc;
2613+
std::string Message;
2614+
2615+
Loc = Node.get<Stmt>()->getBeginLoc();
2616+
Message = "Direct operator[] access on std::unique_ptr<T[]> is unsafe "
2617+
"(no bounds check).";
2618+
S.Diag(Loc, diag::warn_unsafe_buffer_usage_unique_ptr_array_access)
2619+
<< Message << Node.getSourceRange();
2620+
}
2621+
26092622
bool isSafeBufferOptOut(const SourceLocation &Loc) const override {
26102623
return S.PP.isSafeBufferOptOut(S.getSourceManager(), Loc);
26112624
}

0 commit comments

Comments
 (0)