Skip to content

Commit 4fbbede

Browse files
committed
[-Wunsafe-buffer-usage][NFC] Rename PointerAssignment gadget to PtrToPtrAssignment
1 parent e4c9a96 commit 4fbbede

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
@@ -801,21 +801,22 @@ class PointerInitGadget : public FixableGadget {
801801
/// \code
802802
/// p = q;
803803
/// \endcode
804-
class PointerAssignmentGadget : public FixableGadget {
804+
/// where both `p` and `q` are pointers.
805+
class PtrToPtrAssignmentGadget : public FixableGadget {
805806
private:
806807
static constexpr const char *const PointerAssignLHSTag = "ptrLHS";
807808
static constexpr const char *const PointerAssignRHSTag = "ptrRHS";
808809
const DeclRefExpr * PtrLHS; // the LHS pointer expression in `PA`
809810
const DeclRefExpr * PtrRHS; // the RHS pointer expression in `PA`
810811

811812
public:
812-
PointerAssignmentGadget(const MatchFinder::MatchResult &Result)
813-
: FixableGadget(Kind::PointerAssignment),
813+
PtrToPtrAssignmentGadget(const MatchFinder::MatchResult &Result)
814+
: FixableGadget(Kind::PtrToPtrAssignment),
814815
PtrLHS(Result.Nodes.getNodeAs<DeclRefExpr>(PointerAssignLHSTag)),
815816
PtrRHS(Result.Nodes.getNodeAs<DeclRefExpr>(PointerAssignRHSTag)) {}
816817

817818
static bool classof(const Gadget *G) {
818-
return G->getKind() == Kind::PointerAssignment;
819+
return G->getKind() == Kind::PtrToPtrAssignment;
819820
}
820821

821822
static Matcher matcher() {
@@ -1473,7 +1474,7 @@ bool clang::internal::anyConflict(const SmallVectorImpl<FixItHint> &FixIts,
14731474
}
14741475

14751476
std::optional<FixItList>
1476-
PointerAssignmentGadget::getFixits(const FixitStrategy &S) const {
1477+
PtrToPtrAssignmentGadget::getFixits(const FixitStrategy &S) const {
14771478
const auto *LeftVD = cast<VarDecl>(PtrLHS->getDecl());
14781479
const auto *RightVD = cast<VarDecl>(PtrRHS->getDecl());
14791480
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)