Skip to content

Commit 1119a08

Browse files
authored
[BoundsSafety][NFC] Remove the unused parameter 'Decls' from 'Sema::C… (#102076)
…heckCountedByAttrOnField' llvm::SmallVectorImpl<TypeCoupledDeclRefInfo> &Decls is a vector of declarations referred to by the argument of 'counted_by' attributes and fields. 'BuildCountAttributedArrayOrPointerType' had been made self-contained to produce the 'Decls' within itself to allow 'TreeTransform' to invoke the function without having to call 'Sema::CheckCountedByAttrOnField' again. Thus, 'Decls' produced by `Sema::CheckCountedByAttrOnField` is never used.
1 parent 0c2ded6 commit 1119a08

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15071,9 +15071,6 @@ class Sema final : public SemaBase {
1507115071
///
1507215072
/// \param FD The FieldDecl to apply the attribute to
1507315073
/// \param E The count expression on the attribute
15074-
/// \param[out] Decls If the attribute is semantically valid \p Decls
15075-
/// is populated with TypeCoupledDeclRefInfo objects, each
15076-
/// describing Decls referred to in \p E.
1507715074
/// \param CountInBytes If true the attribute is from the "sized_by" family of
1507815075
/// attributes. If the false the attribute is from
1507915076
/// "counted_by" family of attributes.
@@ -15086,10 +15083,8 @@ class Sema final : public SemaBase {
1508615083
/// `counted_by_or_null` attribute.
1508715084
///
1508815085
/// \returns false iff semantically valid.
15089-
bool CheckCountedByAttrOnField(
15090-
FieldDecl *FD, Expr *E,
15091-
llvm::SmallVectorImpl<TypeCoupledDeclRefInfo> &Decls, bool CountInBytes,
15092-
bool OrNull);
15086+
bool CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
15087+
bool OrNull);
1509315088

1509415089
///@}
1509515090
};

clang/lib/Sema/SemaBoundsSafety.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ enum class CountedByInvalidPointeeTypeKind {
4848
VALID,
4949
};
5050

51-
bool Sema::CheckCountedByAttrOnField(
52-
FieldDecl *FD, Expr *E,
53-
llvm::SmallVectorImpl<TypeCoupledDeclRefInfo> &Decls, bool CountInBytes,
54-
bool OrNull) {
51+
bool Sema::CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
52+
bool OrNull) {
5553
// Check the context the attribute is used in
5654

5755
unsigned Kind = getCountAttrKind(CountInBytes, OrNull);
@@ -185,8 +183,6 @@ bool Sema::CheckCountedByAttrOnField(
185183
return true;
186184
}
187185
}
188-
189-
Decls.push_back(TypeCoupledDeclRefInfo(CountFD, /*IsDref*/ false));
190186
return false;
191187
}
192188

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5898,8 +5898,7 @@ static void handleCountedByAttrField(Sema &S, Decl *D, const ParsedAttr &AL) {
58985898
llvm_unreachable("unexpected counted_by family attribute");
58995899
}
59005900

5901-
llvm::SmallVector<TypeCoupledDeclRefInfo, 1> Decls;
5902-
if (S.CheckCountedByAttrOnField(FD, CountExpr, Decls, CountInBytes, OrNull))
5901+
if (S.CheckCountedByAttrOnField(FD, CountExpr, CountInBytes, OrNull))
59035902
return;
59045903

59055904
QualType CAT = S.BuildCountAttributedArrayOrPointerType(

0 commit comments

Comments
 (0)