Skip to content

Commit 7c51e5d

Browse files
[-Wunsafe-buffer-usage] Annotate handlers with maybe_unused (NFC)
Annotate parameters in interop handlers with `[[maybe_unused]]`. (cherry picked from commit 59ba06c)
1 parent c9d322e commit 7c51e5d

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,10 +2548,10 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
25482548
}
25492549

25502550
/* TO_UPSTREAM(BoundsSafety) ON */
2551-
void handleUnsafeCountAttributedPointerArgument(const CallExpr *Call,
2552-
const Expr *Arg,
2553-
bool IsRelatedToDecl,
2554-
ASTContext &Ctx) override {
2551+
void handleUnsafeCountAttributedPointerArgument(
2552+
const CallExpr *Call, const Expr *Arg,
2553+
[[maybe_unused]] bool IsRelatedToDecl,
2554+
[[maybe_unused]] ASTContext &Ctx) override {
25552555
const FunctionDecl *FD = Call->getDirectCallee();
25562556
const auto *FPT = FD->getType()->getAs<FunctionProtoType>();
25572557

@@ -2594,14 +2594,16 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
25942594
<< PtrParamName << CountParamName;
25952595
}
25962596

2597-
void handleUnsafeSinglePointerArgument(const Expr *Arg, bool IsRelatedToDecl,
2598-
ASTContext &Ctx) override {
2597+
void
2598+
handleUnsafeSinglePointerArgument(const Expr *Arg,
2599+
[[maybe_unused]] bool IsRelatedToDecl,
2600+
[[maybe_unused]] ASTContext &Ctx) override {
25992601
S.Diag(Arg->getBeginLoc(), diag::warn_unsafe_single_pointer_argument);
26002602
}
26012603

2602-
void handleTooComplexCountAttributedAssign(const Expr *E, const ValueDecl *VD,
2603-
bool IsRelatedToDecl,
2604-
ASTContext &Ctx) override {
2604+
void handleTooComplexCountAttributedAssign(
2605+
const Expr *E, const ValueDecl *VD, [[maybe_unused]] bool IsRelatedToDecl,
2606+
[[maybe_unused]] ASTContext &Ctx) override {
26052607
SourceLocation Loc = E->getBeginLoc();
26062608
if (const auto *BO = dyn_cast<BinaryOperator>(E))
26072609
Loc = BO->getOperatorLoc();
@@ -2624,11 +2626,10 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26242626
}
26252627
}
26262628

2627-
void handleAssignToImmutableObject(const BinaryOperator *Assign,
2628-
const ValueDecl *VD,
2629-
AssignToImmutableObjectKind Kind,
2630-
bool IsRelatedToDecl,
2631-
ASTContext &Ctx) override {
2629+
void handleAssignToImmutableObject(
2630+
const BinaryOperator *Assign, const ValueDecl *VD,
2631+
AssignToImmutableObjectKind Kind, [[maybe_unused]] bool IsRelatedToDecl,
2632+
[[maybe_unused]] ASTContext &Ctx) override {
26322633
S.Diag(Assign->getOperatorLoc(),
26332634
diag::warn_cannot_assign_to_immutable_bounds_attributed_object)
26342635
<< getBoundsAttributedObjectKind(VD) << VD << Kind;
@@ -2653,8 +2654,8 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26532654
const Expr *LastAssignInGroup,
26542655
const llvm::SmallPtrSetImpl<const ValueDecl *> &Required,
26552656
const llvm::SmallPtrSetImpl<const ValueDecl *> &Missing,
2656-
bool IsRelatedToDecl, ASTContext &Ctx) override {
2657-
2657+
[[maybe_unused]] bool IsRelatedToDecl,
2658+
[[maybe_unused]] ASTContext &Ctx) override {
26582659
llvm::SmallString<64> RequiredAssignments = DeclSetToStr(Required);
26592660
llvm::SmallString<64> MissingAssignments = DeclSetToStr(Missing);
26602661
auto Loc =
@@ -2667,8 +2668,9 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26672668

26682669
void handleDuplicatedAssignment(const BinaryOperator *Assign,
26692670
const BinaryOperator *PrevAssign,
2670-
const ValueDecl *VD, bool IsRelatedToDecl,
2671-
ASTContext &Ctx) override {
2671+
const ValueDecl *VD,
2672+
[[maybe_unused]] bool IsRelatedToDecl,
2673+
[[maybe_unused]] ASTContext &Ctx) override {
26722674
S.Diag(Assign->getOperatorLoc(),
26732675
diag::warn_duplicated_assignment_in_bounds_attributed_group)
26742676
<< getBoundsAttributedObjectKind(VD) << VD;

0 commit comments

Comments
 (0)