[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-25 Thread Erich Keane via cfe-commits
@@ -515,26 +515,94 @@ namespace { Call }; + /// Either a FunctionDecl or an ObjCMethodDecl. This struct papers over the + /// fact that their common ancestors are DeclContext and NamedDecl, which + /// does not allow the enumeration of their parameters very easily. +

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread John McCall via cfe-commits
rjmccall wrote: I haven't looked at your patch yet, and I'm not familiar with the `diagnose_if` feature; I'm just commenting about the AST design question because I was tagged in to do so. If `diagnose_if` is about compile-time evaluation — essentially assertion failures during constant evalua

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread via cfe-commits
apple-fcloutier wrote: This is a design space that is large for a person who does not know Clang's internals and history very well, but that seems fairly narrow for someone with a lot of experience. As a matter of fact, [there is a CallableDecl](https://github.com/llvm/llvm-project/pull/115056

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread John McCall via cfe-commits
rjmccall wrote: > An abstraction that includes blocks doesn't help us here because we are > looking for the combination of `NamedDecl` and `DeclContext` and `BlockDecl` > isn't a `NamedDecl`. I think you're focusing a little narrowly here. I can't imagine why you'd specifically need a `NamedD

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread via cfe-commits
apple-fcloutier wrote: An abstraction that includes blocks doesn't help us here because we are looking for the combination of `NamedDecl` and `DeclContext` and `BlockDecl` isn't a `NamedDecl`. Aaron, I'm not sure I understand you correctly, but ObjCMethodDecl doesn't have a type. What would i

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-22 Thread Aaron Ballman via cfe-commits
AaronBallman wrote: I agree that having something tying these together would be nice, but should we also tie them together at the `Type` level similarly, or just the `Decl` level? https://github.com/llvm/llvm-project/pull/115056 ___ cfe-commits mailin

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-21 Thread John McCall via cfe-commits
rjmccall wrote: Having an abstraction for this would be nice. It doesn't *have* to be a base class specifically, though; we can do a more extrinsic tagged-union without actually unifying the class hierarchies, like `llvm::CallSite` does. Swift has a type called `AnyFunctionRef` that unifies se

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-21 Thread Akira Hatanaka via cfe-commits
ahatanak wrote: > There is almost certainly value in introducing a base class beneath > ObjCMethodDecl and FunctionDecl that is both a NamedDecl and a DeclContext, > because I'm not the first person to run into this problem. If I do the work, > whose review/approval do we need? Is it deep enou

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-21 Thread via cfe-commits
apple-fcloutier wrote: I think there's limited value to diagnose_if on blocks, since that will apply to a variable of block type and not to the block type. In other words, given this: ```c void (^block)(int *) = ^(int *p) __attribute__((diagnose_if(p == 0, "p is NULL"))) { ... }; block(0); ``

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-20 Thread Akira Hatanaka via cfe-commits
ahatanak wrote: > I wish I didn't need to change the ExprConstant call stack machinery like > this, happy to take suggestions. This is all because the closest ancestors of > FunctionDecl and ObjCMethodDecl are NamedDecl and DeclGroup. Should we enable `diagnose_if` for block methods too? ```

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-18 Thread via cfe-commits
AreaZR wrote: Any update on this? https://github.com/llvm/llvm-project/pull/115056 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-05 Thread via cfe-commits
apple-fcloutier wrote: I wish I didn't need to change the ExprConstant call stack machinery like this, happy to take suggestions. This is all because the closest ancestors of FunctionDecl and ObjCMethodDecl are NamedDecl and DeclGroup. https://github.com/llvm/llvm-project/pull/115056 _

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-05 Thread via cfe-commits
https://github.com/apple-fcloutier updated https://github.com/llvm/llvm-project/pull/115056 >From f74e55dac7d5b28852dbb16455c5f4f083fde8dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Cloutier?= Date: Fri, 25 Oct 2024 14:41:28 -0700 Subject: [PATCH] [ObjC] Enable diagnose_if on Objecti

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-05 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 17d956588a2cc508acf98574f913eaef6d0e1af3 802e8e85de3b3d0a8c6ccd4f7ac3536f10183ea2 --e

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-05 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: None (apple-fcloutier) Changes This change enables checking argument-dependent `diagnose_if` diagnostics on Objective-C methods. It changes EvaluateWithSubstitution to accept any NamedDecl, concretely expecting them to be either Function

[clang] [ObjC] Enable diagnose_if on Objective-C methods (PR #115056)

2024-11-05 Thread via cfe-commits
https://github.com/apple-fcloutier created https://github.com/llvm/llvm-project/pull/115056 This change enables checking argument-dependent `diagnose_if` diagnostics on Objective-C methods. It changes EvaluateWithSubstitution to accept any NamedDecl, concretely expecting them to be either Fun