Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions clang/lib/Sema/AnalysisBasedWarnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2558,10 +2558,10 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
}

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

Expand Down Expand Up @@ -2604,14 +2604,16 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
<< PtrParamName << CountParamName;
}

void handleUnsafeSinglePointerArgument(const Expr *Arg, bool IsRelatedToDecl,
ASTContext &Ctx) override {
void
handleUnsafeSinglePointerArgument(const Expr *Arg,
[[maybe_unused]] bool IsRelatedToDecl,
[[maybe_unused]] ASTContext &Ctx) override {
S.Diag(Arg->getBeginLoc(), diag::warn_unsafe_single_pointer_argument);
}

void handleTooComplexCountAttributedAssign(const Expr *E, const ValueDecl *VD,
bool IsRelatedToDecl,
ASTContext &Ctx) override {
void handleTooComplexCountAttributedAssign(
const Expr *E, const ValueDecl *VD, [[maybe_unused]] bool IsRelatedToDecl,
[[maybe_unused]] ASTContext &Ctx) override {
SourceLocation Loc = E->getBeginLoc();
if (const auto *BO = dyn_cast<BinaryOperator>(E))
Loc = BO->getOperatorLoc();
Expand All @@ -2634,11 +2636,10 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
}
}

void handleAssignToImmutableObject(const BinaryOperator *Assign,
const ValueDecl *VD,
AssignToImmutableObjectKind Kind,
bool IsRelatedToDecl,
ASTContext &Ctx) override {
void handleAssignToImmutableObject(
const BinaryOperator *Assign, const ValueDecl *VD,
AssignToImmutableObjectKind Kind, [[maybe_unused]] bool IsRelatedToDecl,
[[maybe_unused]] ASTContext &Ctx) override {
S.Diag(Assign->getOperatorLoc(),
diag::warn_cannot_assign_to_immutable_bounds_attributed_object)
<< getBoundsAttributedObjectKind(VD) << VD << Kind;
Expand All @@ -2663,8 +2664,8 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {
const Expr *LastAssignInGroup,
const llvm::SmallPtrSetImpl<const ValueDecl *> &Required,
const llvm::SmallPtrSetImpl<const ValueDecl *> &Missing,
bool IsRelatedToDecl, ASTContext &Ctx) override {

[[maybe_unused]] bool IsRelatedToDecl,
[[maybe_unused]] ASTContext &Ctx) override {
llvm::SmallString<64> RequiredAssignments = DeclSetToStr(Required);
llvm::SmallString<64> MissingAssignments = DeclSetToStr(Missing);
auto Loc =
Expand All @@ -2677,8 +2678,9 @@ class UnsafeBufferUsageReporter : public UnsafeBufferUsageHandler {

void handleDuplicatedAssignment(const BinaryOperator *Assign,
const BinaryOperator *PrevAssign,
const ValueDecl *VD, bool IsRelatedToDecl,
ASTContext &Ctx) override {
const ValueDecl *VD,
[[maybe_unused]] bool IsRelatedToDecl,
[[maybe_unused]] ASTContext &Ctx) override {
S.Diag(Assign->getOperatorLoc(),
diag::warn_duplicated_assignment_in_bounds_attributed_group)
<< getBoundsAttributedObjectKind(VD) << VD;
Expand Down