Skip to content

Commit 1b12f74

Browse files
committed
[-Wunsafe-buffer-usage][NFC] Rename PointerAssignment gadget to PtrToPtrAssignment
1 parent 791130c commit 1b12f74

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

clang/include/clang/Analysis/Analyses/UnsafeBufferUsageGadgets.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ FIXABLE_GADGET(UPCAddressofArraySubscript) // '&DRE[any]' in an Unspecified Poin
4545
FIXABLE_GADGET(UPCStandalonePointer)
4646
FIXABLE_GADGET(UPCPreIncrement) // '++Ptr' in an Unspecified Pointer Context
4747
FIXABLE_GADGET(UUCAddAssign) // 'Ptr += n' in an Unspecified Untyped Context
48-
FIXABLE_GADGET(PointerAssignment)
48+
FIXABLE_GADGET(PtrToPtrAssignment)
4949
FIXABLE_GADGET(PointerInit)
5050

5151
#undef FIXABLE_GADGET

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,21 +799,22 @@ class PointerInitGadget : public FixableGadget {
799799
/// \code
800800
/// p = q;
801801
/// \endcode
802-
class PointerAssignmentGadget : public FixableGadget {
802+
/// where both `p` and `q` are pointers.
803+
class PtrToPtrAssignmentGadget : public FixableGadget {
803804
private:
804805
static constexpr const char *const PointerAssignLHSTag = "ptrLHS";
805806
static constexpr const char *const PointerAssignRHSTag = "ptrRHS";
806807
const DeclRefExpr * PtrLHS; // the LHS pointer expression in `PA`
807808
const DeclRefExpr * PtrRHS; // the RHS pointer expression in `PA`
808809

809810
public:
810-
PointerAssignmentGadget(const MatchFinder::MatchResult &Result)
811-
: FixableGadget(Kind::PointerAssignment),
811+
PtrToPtrAssignmentGadget(const MatchFinder::MatchResult &Result)
812+
: FixableGadget(Kind::PtrToPtrAssignment),
812813
PtrLHS(Result.Nodes.getNodeAs<DeclRefExpr>(PointerAssignLHSTag)),
813814
PtrRHS(Result.Nodes.getNodeAs<DeclRefExpr>(PointerAssignRHSTag)) {}
814815

815816
static bool classof(const Gadget *G) {
816-
return G->getKind() == Kind::PointerAssignment;
817+
return G->getKind() == Kind::PtrToPtrAssignment;
817818
}
818819

819820
static Matcher matcher() {
@@ -1471,7 +1472,7 @@ bool clang::internal::anyConflict(const SmallVectorImpl<FixItHint> &FixIts,
14711472
}
14721473

14731474
std::optional<FixItList>
1474-
PointerAssignmentGadget::getFixits(const FixitStrategy &S) const {
1475+
PtrToPtrAssignmentGadget::getFixits(const FixitStrategy &S) const {
14751476
const auto *LeftVD = cast<VarDecl>(PtrLHS->getDecl());
14761477
const auto *RightVD = cast<VarDecl>(PtrRHS->getDecl());
14771478
switch (S.lookup(LeftVD)) {

clang/test/SemaCXX/warn-unsafe-buffer-usage-debug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void unclaimed_use() {
5353
void implied_unclaimed_var(int *b) { // expected-warning{{'b' is an unsafe pointer used for buffer access}}
5454
int *a = new int[3]; // expected-warning{{'a' is an unsafe pointer used for buffer access}}
5555
a[4] = 7; // expected-note{{used in buffer access here}}
56-
a = b; // debug-note{{safe buffers debug: gadget 'PointerAssignment' refused to produce a fix}}
56+
a = b; // debug-note{{safe buffers debug: gadget 'PtrToPtrAssignment' refused to produce a fix}}
5757
b++; // expected-note{{used in pointer arithmetic here}} \
5858
// debug-note{{safe buffers debug: failed to produce fixit for 'b' : has an unclaimed use}}
5959
}

0 commit comments

Comments
 (0)