Skip to content

Commit 0b6dcc7

Browse files
committed
[-Wunsafe-buffer-usage][NFC] Rename PointerAssignment gadget to PtrToPtrAssignment
1 parent 46166ba commit 0b6dcc7

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
@@ -762,21 +762,22 @@ class PointerInitGadget : public FixableGadget {
762762
/// \code
763763
/// p = q;
764764
/// \endcode
765-
class PointerAssignmentGadget : public FixableGadget {
765+
/// where both `p` and `q` are pointers.
766+
class PtrToPtrAssignmentGadget : public FixableGadget {
766767
private:
767768
static constexpr const char *const PointerAssignLHSTag = "ptrLHS";
768769
static constexpr const char *const PointerAssignRHSTag = "ptrRHS";
769770
const DeclRefExpr * PtrLHS; // the LHS pointer expression in `PA`
770771
const DeclRefExpr * PtrRHS; // the RHS pointer expression in `PA`
771772

772773
public:
773-
PointerAssignmentGadget(const MatchFinder::MatchResult &Result)
774-
: FixableGadget(Kind::PointerAssignment),
774+
PtrToPtrAssignmentGadget(const MatchFinder::MatchResult &Result)
775+
: FixableGadget(Kind::PtrToPtrAssignment),
775776
PtrLHS(Result.Nodes.getNodeAs<DeclRefExpr>(PointerAssignLHSTag)),
776777
PtrRHS(Result.Nodes.getNodeAs<DeclRefExpr>(PointerAssignRHSTag)) {}
777778

778779
static bool classof(const Gadget *G) {
779-
return G->getKind() == Kind::PointerAssignment;
780+
return G->getKind() == Kind::PtrToPtrAssignment;
780781
}
781782

782783
static Matcher matcher() {
@@ -1434,7 +1435,7 @@ bool clang::internal::anyConflict(const SmallVectorImpl<FixItHint> &FixIts,
14341435
}
14351436

14361437
std::optional<FixItList>
1437-
PointerAssignmentGadget::getFixits(const FixitStrategy &S) const {
1438+
PtrToPtrAssignmentGadget::getFixits(const FixitStrategy &S) const {
14381439
const auto *LeftVD = cast<VarDecl>(PtrLHS->getDecl());
14391440
const auto *RightVD = cast<VarDecl>(PtrRHS->getDecl());
14401441
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)