[clang] [Clang] handle [[warn_unused]] attribute for unused private fields (PR #120734)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 19 01:51:34 PST 2025
================
@@ -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) {
----------------
tbaederr wrote:
The `inline` in the static functions should go I think, and I hope the `FieldDecl` here can be `const`.
https://github.com/llvm/llvm-project/pull/120734
More information about the cfe-commits
mailing list