Skip to content

Commit 59ba06c

Browse files
[-Wunsafe-buffer-usage] Annotate handlers with maybe_unused (NFC)
Annotate parameters in interop handlers with `[[maybe_unused]]`.
1 parent ce46ba8 commit 59ba06c

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
@@ -2558,10 +2558,10 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
25582558
}
25592559

25602560
/* TO_UPSTREAM(BoundsSafety) ON */
2561-
void handleUnsafeCountAttributedPointerArgument(const CallExpr *Call,
2562-
const Expr *Arg,
2563-
bool IsRelatedToDecl,
2564-
ASTContext &Ctx) override {
2561+
void handleUnsafeCountAttributedPointerArgument(
2562+
const CallExpr *Call, const Expr *Arg,
2563+
[[maybe_unused]] bool IsRelatedToDecl,
2564+
[[maybe_unused]] ASTContext &Ctx) override {
25652565
const FunctionDecl *FD = Call->getDirectCallee();
25662566
const auto *FPT = FD->getType()->getAs<FunctionProtoType>();
25672567

@@ -2604,14 +2604,16 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26042604
<< PtrParamName << CountParamName;
26052605
}
26062606

2607-
void handleUnsafeSinglePointerArgument(const Expr *Arg, bool IsRelatedToDecl,
2608-
ASTContext &Ctx) override {
2607+
void
2608+
handleUnsafeSinglePointerArgument(const Expr *Arg,
2609+
[[maybe_unused]] bool IsRelatedToDecl,
2610+
[[maybe_unused]] ASTContext &Ctx) override {
26092611
S.Diag(Arg->getBeginLoc(), diag::warn_unsafe_single_pointer_argument);
26102612
}
26112613

2612-
void handleTooComplexCountAttributedAssign(const Expr *E, const ValueDecl *VD,
2613-
bool IsRelatedToDecl,
2614-
ASTContext &Ctx) override {
2614+
void handleTooComplexCountAttributedAssign(
2615+
const Expr *E, const ValueDecl *VD, [[maybe_unused]] bool IsRelatedToDecl,
2616+
[[maybe_unused]] ASTContext &Ctx) override {
26152617
SourceLocation Loc = E->getBeginLoc();
26162618
if (const auto *BO = dyn_cast<BinaryOperator>(E))
26172619
Loc = BO->getOperatorLoc();
@@ -2634,11 +2636,10 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26342636
}
26352637
}
26362638

2637-
void handleAssignToImmutableObject(const BinaryOperator *Assign,
2638-
const ValueDecl *VD,
2639-
AssignToImmutableObjectKind Kind,
2640-
bool IsRelatedToDecl,
2641-
ASTContext &Ctx) override {
2639+
void handleAssignToImmutableObject(
2640+
const BinaryOperator *Assign, const ValueDecl *VD,
2641+
AssignToImmutableObjectKind Kind, [[maybe_unused]] bool IsRelatedToDecl,
2642+
[[maybe_unused]] ASTContext &Ctx) override {
26422643
S.Diag(Assign->getOperatorLoc(),
26432644
diag::warn_cannot_assign_to_immutable_bounds_attributed_object)
26442645
<< getBoundsAttributedObjectKind(VD) << VD << Kind;
@@ -2663,8 +2664,8 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26632664
const Expr *LastAssignInGroup,
26642665
const llvm::SmallPtrSetImpl<const ValueDecl *> &Required,
26652666
const llvm::SmallPtrSetImpl<const ValueDecl *> &Missing,
2666-
bool IsRelatedToDecl, ASTContext &Ctx) override {
2667-
2667+
[[maybe_unused]] bool IsRelatedToDecl,
2668+
[[maybe_unused]] ASTContext &Ctx) override {
26682669
llvm::SmallString<64> RequiredAssignments = DeclSetToStr(Required);
26692670
llvm::SmallString<64> MissingAssignments = DeclSetToStr(Missing);
26702671
auto Loc =
@@ -2677,8 +2678,9 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
26772678

26782679
void handleDuplicatedAssignment(const BinaryOperator *Assign,
26792680
const BinaryOperator *PrevAssign,
2680-
const ValueDecl *VD, bool IsRelatedToDecl,
2681-
ASTContext &Ctx) override {
2681+
const ValueDecl *VD,
2682+
[[maybe_unused]] bool IsRelatedToDecl,
2683+
[[maybe_unused]] ASTContext &Ctx) override {
26822684
S.Diag(Assign->getOperatorLoc(),
26832685
diag::warn_duplicated_assignment_in_bounds_attributed_group)
26842686
<< getBoundsAttributedObjectKind(VD) << VD;

0 commit comments

Comments
 (0)