Skip to content

Commit

Permalink
[-Wunsafe-buffer-usage] Fix a fallthrough case in UPCStandalonePointe…
Browse files Browse the repository at this point in the history
…r getFixits

Differential Revision: https://reviews.llvm.org/D155526
  • Loading branch information
t-rasmud committed Jul 25, 2023
1 parent 1b162fa commit 070358e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/Analysis/UnsafeBufferUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,8 @@ PointerDereferenceGadget::getFixits(const Strategy &S) const {
FixItHint::CreateInsertion(
(*EndOfOperand).getLocWithOffset(1), "[0]")}};
}
break;
}
[[fallthrough]];
case Strategy::Kind::Iterator:
case Strategy::Kind::Array:
case Strategy::Kind::Vector:
Expand Down Expand Up @@ -1541,8 +1541,9 @@ std::optional<FixItList> UPCStandalonePointerGadget::getFixits(const Strategy &S
if (EndOfOperand)
return FixItList{{FixItHint::CreateInsertion(
*EndOfOperand, ".data()")}};
// FIXME: Points inside a macro expansion.
break;
}
[[fallthrough]];
case Strategy::Kind::Wontfix:
case Strategy::Kind::Iterator:
case Strategy::Kind::Array:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions -verify %s

// expected-no-diagnostics

typedef unsigned __darwin_size_t;
typedef __darwin_size_t size_t;
#define bzero(s, n) __builtin_bzero(s, n)
void __nosan_bzero(void *dst, size_t sz) { bzero(dst, sz); }

0 comments on commit 070358e

Please sign in to comment.