================
@@ -1013,6 +1013,17 @@ void Sema::InstantiateAttrs(const
MultiLevelTemplateArgumentList &TemplateArgs,
continue;
}
+ if (auto *A = dyn_cast<ReturnsNonNullAttr>(TmplAttr)) {
+ auto *FD = cast<FunctionDecl>(New);
+ QualType ResultType = getFunctionOrMethodResultType(FD);
+ if (!isValidPointerAttrType(ResultType))
+ Diag(A->getLocation(), diag::warn_attribute_return_pointers_only)
+ << A << SourceRange() << getFunctionOrMethodResultSourceRange(FD);
+ else if (!New->hasAttr<ReturnsNonNullAttr>())
+ New->addAttr(A->clone(Context));
+ continue;
+ }
+
----------------
el-ev wrote:
I'm considering adding a common checker for `warn_attribute_pointers_only`,
`warn_attribute_return_pointers_only` and
`warn_attribute_return_pointers_refs_only`in a follow-up pr. There are about 8
call sites of them combined. Is that okay?
https://github.com/llvm/llvm-project/pull/200117
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits