Skip to content

Commit 38a2d44

Browse files
committed
fix compilation issues and test
1 parent 4c95972 commit 38a2d44

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13241,7 +13241,7 @@ def warn_unsafe_buffer_usage_in_container : Warning<
1324113241
"the two-parameter std::span construction is unsafe as it can introduce mismatch between buffer size and the bound information">,
1324213242
InGroup<UnsafeBufferUsageInContainer>, DefaultIgnore;
1324313243
def warn_unsafe_buffer_usage_unique_ptr_array_access : Warning<"direct access using operator[] on std::unique_ptr<T[]> is unsafe due to lack of bounds checking">,
13244-
InGroup<UnsafeBufferUsageInUniquePtrArray>, DefaultIgnore;
13244+
InGroup<UnsafeBufferUsageInUniquePtrArrayAccess>, DefaultIgnore;
1324513245
#ifndef NDEBUG
1324613246
// Not a user-facing diagnostic. Useful for debugging false negatives in
1324713247
// -fsafe-buffer-usage-suggestions (i.e. lack of -Wunsafe-buffer-usage fixits).

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,10 +2732,13 @@ std::set<const Expr *> clang::findUnsafePointers(const FunctionDecl *FD) {
27322732
const VariableGroupsManager &, FixItList &&,
27332733
const Decl *,
27342734
const FixitStrategy &) override {}
2735-
bool isSafeBufferOptOut(const SourceLocation &) const override {
2735+
void handleUnsafeUniquePtrArrayAccess(const DynTypedNode &Node,
2736+
bool IsRelatedToDecl,
2737+
ASTContext &Ctx) override {}
2738+
bool ignoreUnsafeBufferInContainer(const SourceLocation &) const override {
27362739
return false;
27372740
}
2738-
bool ignoreUnsafeBufferInContainer(const SourceLocation &) const override {
2741+
bool isSafeBufferOptOut(const SourceLocation &) const override {
27392742
return false;
27402743
}
27412744
bool ignoreUnsafeBufferInLibcCall(const SourceLocation &) const override {
@@ -2747,10 +2750,6 @@ std::set<const Expr *> clang::findUnsafePointers(const FunctionDecl *FD) {
27472750
}
27482751
};
27492752

2750-
void handleUnsafeUniquePtrArrayAccess(const DynTypedNode &Node,
2751-
bool IsRelatedToDecl,
2752-
ASTContext &Ctx) override {}
2753-
27542753
FixableGadgetList FixableGadgets;
27552754
WarningGadgetList WarningGadgets;
27562755
DeclUseTracker Tracker;

clang/test/SemaCXX/warn-unsafe-buffer-usage-debug-unclaimed/warn-unsafe-buffer-usage-debug-unclaimed.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ template <class T> class unique_ptr {
4343

4444
void basic_unique_ptr() {
4545
std::unique_ptr<int[]> p1;
46-
p1[0]; // expected-warning{{direct access using operator[] on
47-
// std::unique_ptr<T[]> is unsafe due to lack of bounds checking}}
46+
p1[0]; // expected-warning{{direct access using operator[] on std::unique_ptr<T[]> is unsafe due to lack of bounds checking}}
4847
}
4948

5049
// CHECK: Root # 1

0 commit comments

Comments
 (0)