[clang] [Clang] handle [[warn_unused]] attribute for unused private fields (PR #120734)
Oleksandr T. via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 20 16:16:09 PST 2024
================
@@ -3307,6 +3307,29 @@ void Sema::CheckShadowInheritedFields(const SourceLocation &Loc,
}
}
+template <typename AttrType>
+inline static bool HasAttribute(const QualType &T) {
+ if (const TagDecl *TD = T->getAsTagDecl())
+ return TD->hasAttr<AttrType>();
+ if (const TypedefType *TDT = T->getAs<TypedefType>())
+ return TDT->getDecl()->hasAttr<AttrType>();
+ return false;
+}
+
+inline static bool IsUnusedPrivateField(FieldDecl *FD) {
+ if (FD->getAccess() == AS_private && FD->getDeclName()) {
+ QualType FieldType = FD->getType();
----------------
a-tarasyuk wrote:
@erichkeane I'll check, though I remember it seems like it can only be used with structs, unions, and classes.
https://github.com/llvm/llvm-project/pull/120734
More information about the cfe-commits
mailing list