[clang] [clang] Implement -Walloc-size diagnostic option (PR #150028)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 22 07:28:19 PDT 2025
================
@@ -3542,6 +3542,59 @@ bool CallExpr::isBuiltinAssumeFalse(const ASTContext &Ctx) const {
Arg->EvaluateAsBooleanCondition(ArgVal, Ctx) && !ArgVal;
}
+const AllocSizeAttr *CallExpr::getAllocSizeAttr() const {
+ if (const FunctionDecl *DirectCallee = getDirectCallee())
+ return DirectCallee->getAttr<AllocSizeAttr>();
+ if (const Decl *IndirectCallee = getCalleeDecl())
+ return IndirectCallee->getAttr<AllocSizeAttr>();
+ return nullptr;
----------------
erichkeane wrote:
I suspect the callee would have to do it, but we could try a little harder by 'making one up' for things like `__builtin_malloc`/etc. Wondering if we have any other builtins... Perhaps a task for a future patch.
https://github.com/llvm/llvm-project/pull/150028
More information about the cfe-commits
mailing list