Skip to content

Commit 070358e

Browse files
committed
[-Wunsafe-buffer-usage] Fix a fallthrough case in UPCStandalonePointer getFixits
Differential Revision: https://reviews.llvm.org/D155526
1 parent 1b162fa commit 070358e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,8 @@ PointerDereferenceGadget::getFixits(const Strategy &S) const {
15121512
FixItHint::CreateInsertion(
15131513
(*EndOfOperand).getLocWithOffset(1), "[0]")}};
15141514
}
1515+
break;
15151516
}
1516-
[[fallthrough]];
15171517
case Strategy::Kind::Iterator:
15181518
case Strategy::Kind::Array:
15191519
case Strategy::Kind::Vector:
@@ -1541,8 +1541,9 @@ std::optional<FixItList> UPCStandalonePointerGadget::getFixits(const Strategy &S
15411541
if (EndOfOperand)
15421542
return FixItList{{FixItHint::CreateInsertion(
15431543
*EndOfOperand, ".data()")}};
1544+
// FIXME: Points inside a macro expansion.
1545+
break;
15441546
}
1545-
[[fallthrough]];
15461547
case Strategy::Kind::Wontfix:
15471548
case Strategy::Kind::Iterator:
15481549
case Strategy::Kind::Array:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fsafe-buffer-usage-suggestions -verify %s
2+
3+
// expected-no-diagnostics
4+
5+
typedef unsigned __darwin_size_t;
6+
typedef __darwin_size_t size_t;
7+
#define bzero(s, n) __builtin_bzero(s, n)
8+
void __nosan_bzero(void *dst, size_t sz) { bzero(dst, sz); }

0 commit comments

Comments
 (0)