[clang-tools-extra] [clang][include-cleaner] Support ObjC @selector expressions in WalkAST (PR #212564)
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 12 22:11:38 PDT 2026
================
@@ -39,8 +43,42 @@ bool isOperatorNewDelete(OverloadedOperatorKind OpKind) {
using DeclCallback =
llvm::function_ref<void(SourceLocation, NamedDecl &, RefType)>;
+class ObjCSelectorDeclMapBuilder
+ : public RecursiveASTVisitor<ObjCSelectorDeclMapBuilder> {
+public:
+ ObjCSelectorMap takeMap() { return std::move(Map); }
+
+ bool TraverseDecl(clang::Decl *D) {
+ if (!D)
+ return true;
+ if (auto *Container = llvm::dyn_cast<clang::ObjCContainerDecl>(D)) {
+ for (clang::ObjCMethodDecl *M : Container->methods()) {
----------------
nico wrote:
For `@property int foo`, won't this here push_back both the synthesized `-foo` getter and the property itself?
(If this turns out to be true, maybe add a test that's sensitive to this.)
Maybe override VisitObjCMethodDecl or VisitObjCPropertyDecl instead of manually traversing?
https://github.com/llvm/llvm-project/pull/212564
More information about the cfe-commits
mailing list