[clang] Diagnose misuse of the cleanup attribute (PR #80040)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 08:48:55 PST 2024


AaronBallman wrote:

> tried to implement the requested changes along the new direction, I have some queries should I let this statament as is or assign to a variable:
> 
> ```
> S.CheckFunctionCall(FD, FunctionCallExpression,
>                       FD->getType()->getAs<FunctionProtoType>());
> ```

That call only returns `false` but I would still wrap the call in an `if` statement, as in:
```
if (S.CheckFunctionCall(...))
  return;
```
and I would move the code up above where we call `addAttr()`. The basic idea is: if `CheckFunctionCall()` ever gets updated to return `true` on failure, then we'll skip adding the problematic attribute to the declaration.

> Further I request some guidance on how to use `malloc` & `free` etc , standard library functions in tests. Added Release notes but not sure about its framing.

We want our tests to be hermetic (not relying on anything specific to the developer's setup), so tests for this sort of thing will declare `free` manually. e.g,
```
extern void free(void *);
```

https://github.com/llvm/llvm-project/pull/80040


More information about the cfe-commits mailing list