Skip to content

Commit e5cebec

Browse files
[-Wunsafe-buffer-usage] Fix AST matcher of UUCAddAssignGadget (#79392)
We are not interested in nonpointers being added to.
1 parent 75ea78a commit e5cebec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,11 +1192,16 @@ class UUCAddAssignGadget : public FixableGadget {
11921192
}
11931193

11941194
static Matcher matcher() {
1195+
// clang-format off
11951196
return stmt(isInUnspecifiedUntypedContext(expr(ignoringImpCasts(
11961197
binaryOperator(hasOperatorName("+="),
1197-
hasLHS(declRefExpr(toSupportedVariable())),
1198+
hasLHS(
1199+
declRefExpr(
1200+
hasPointerType(),
1201+
toSupportedVariable())),
11981202
hasRHS(expr().bind(OffsetTag)))
11991203
.bind(UUCAddAssignTag)))));
1204+
// clang-format on
12001205
}
12011206

12021207
virtual std::optional<FixItList> getFixits(const Strategy &S) const override;

0 commit comments

Comments
 (0)