[clang] [clang][Sema] fix -Wunused-private-field false-positive when use is templated (PR #237374)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 21:36:25 PST 2026
================
@@ -4955,6 +4955,34 @@ const FieldDecl *FieldDecl::findCountedByField() const {
return dyn_cast<FieldDecl>(CountDecl);
}
+static bool InitializationHasSideEffects(const FieldDecl &FD) {
+ const Type *T = FD.getType()->getBaseElementTypeUnsafe();
+ // FIXME: Destruction of ObjC lifetime types has side-effects.
+ if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+ return !RD->isCompleteDefinition() || !RD->hasTrivialDefaultConstructor() ||
+ !RD->hasTrivialDestructor();
+ return false;
+}
+
+template <typename AttrType> static bool HasAttribute(const QualType &T) {
----------------
tbaederr wrote:
```suggestion
template <typename AttrType> static bool hasAttribute(QualType T) {
```
https://github.com/llvm/llvm-project/pull/237374
More information about the cfe-commits
mailing list