[clang] [clang-tools-extra] [clang-include-cleaner] Make cleanup attr report expr location (PR #140233)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon May 19 11:23:25 PDT 2025
================
@@ -1351,7 +1352,8 @@ def OSConsumesThis : InheritableAttr {
def Cleanup : InheritableAttr {
let Spellings = [GCC<"cleanup">];
- let Args = [DeclArgument<Function, "FunctionDecl">];
+ let Args = [DeclArgument<Function, "FunctionDecl">,
+ ExprArgument<"Expr", /*opt=*/0, /*fake=*/1>];
----------------
AaronBallman wrote:
I'm not keen on this solution. There are three approaches that would be better:
1) Change to accept a `DeclRefExpr` instead, add an additional method here to get the `FunctionDecl` out of the expression.
2) Add an extra `SourceLocation` member here, then update `handleCleanupAttr()` to set the source location to the location of the expression argument.
3) Generically expose expression arguments on the `Attr` subclass.
I think #3 is where we'd ultimately like to go, but is also probably a decent amount of work given how many attributes we have. I think #1 may be the most reasonable solution here, while #2 is likely the easiest.
CC @erichkeane
https://github.com/llvm/llvm-project/pull/140233
More information about the cfe-commits
mailing list