-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[Clang] [NFC] Migrate visitors in ARCMigrate #116792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang Author: None (Sirraide) ChangesThis pr migrates AST visitors in This is part of an ongoing refactor. For more context, see #110040, #93462. Most of the visitors were fairly simple to migrate, but one that I wasn’t fully able to untangle was If you think the way I went about dealing w/ Patch is 38.79 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/116792.diff 16 Files Affected:
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index c1bc7c762088f2..9e237897327111 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -7,16 +7,16 @@
//===----------------------------------------------------------------------===//
#include "Transforms.h"
-#include "clang/Analysis/RetainSummaryManager.h"
#include "clang/ARCMigrate/ARCMT.h"
#include "clang/ARCMigrate/ARCMTActions.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/AST/NSAPI.h"
#include "clang/AST/ParentMap.h"
-#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Analysis/DomainSpecific/CocoaConventions.h"
+#include "clang/Analysis/RetainSummaryManager.h"
#include "clang/Basic/FileManager.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/EditedSource.h"
@@ -309,67 +309,68 @@ namespace {
return true;
}
-class ObjCMigrator : public RecursiveASTVisitor<ObjCMigrator> {
- ObjCMigrateASTConsumer &Consumer;
- ParentMap &PMap;
-
-public:
- ObjCMigrator(ObjCMigrateASTConsumer &consumer, ParentMap &PMap)
- : Consumer(consumer), PMap(PMap) { }
-
- bool shouldVisitTemplateInstantiations() const { return false; }
- bool shouldWalkTypesOfTypeLocs() const { return false; }
+ class ObjCMigrator : public DynamicRecursiveASTVisitor {
+ ObjCMigrateASTConsumer &Consumer;
+ ParentMap &PMap;
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
- if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) {
- edit::Commit commit(*Consumer.Editor);
- edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap);
- Consumer.Editor->commit(commit);
+ public:
+ ObjCMigrator(ObjCMigrateASTConsumer &consumer, ParentMap &PMap)
+ : Consumer(consumer), PMap(PMap) {
+ ShouldVisitTemplateInstantiations = false;
+ ShouldWalkTypesOfTypeLocs = false;
}
- if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) {
- edit::Commit commit(*Consumer.Editor);
- edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit);
- Consumer.Editor->commit(commit);
- }
+ bool VisitObjCMessageExpr(ObjCMessageExpr *E) override {
+ if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) {
+ edit::Commit commit(*Consumer.Editor);
+ edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap);
+ Consumer.Editor->commit(commit);
+ }
- if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_PropertyDotSyntax) {
- edit::Commit commit(*Consumer.Editor);
- rewriteToPropertyDotSyntax(E, Consumer.PP, *Consumer.NSAPIObj,
- commit, &PMap);
- Consumer.Editor->commit(commit);
- }
+ if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) {
+ edit::Commit commit(*Consumer.Editor);
+ edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit);
+ Consumer.Editor->commit(commit);
+ }
- return true;
- }
+ if (Consumer.ASTMigrateActions &
+ FrontendOptions::ObjCMT_PropertyDotSyntax) {
+ edit::Commit commit(*Consumer.Editor);
+ rewriteToPropertyDotSyntax(E, Consumer.PP, *Consumer.NSAPIObj, commit,
+ &PMap);
+ Consumer.Editor->commit(commit);
+ }
- bool TraverseObjCMessageExpr(ObjCMessageExpr *E) {
- // Do depth first; we want to rewrite the subexpressions first so that if
- // we have to move expressions we will move them already rewritten.
- for (Stmt *SubStmt : E->children())
- if (!TraverseStmt(SubStmt))
- return false;
+ return true;
+ }
- return WalkUpFromObjCMessageExpr(E);
- }
-};
+ bool TraverseObjCMessageExpr(ObjCMessageExpr *E) override {
+ // Do depth first; we want to rewrite the subexpressions first so that if
+ // we have to move expressions we will move them already rewritten.
+ for (Stmt *SubStmt : E->children())
+ if (!TraverseStmt(SubStmt))
+ return false;
-class BodyMigrator : public RecursiveASTVisitor<BodyMigrator> {
- ObjCMigrateASTConsumer &Consumer;
- std::unique_ptr<ParentMap> PMap;
+ return WalkUpFromObjCMessageExpr(E);
+ }
+ };
-public:
- BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) { }
+ class BodyMigrator : public DynamicRecursiveASTVisitor {
+ ObjCMigrateASTConsumer &Consumer;
+ std::unique_ptr<ParentMap> PMap;
- bool shouldVisitTemplateInstantiations() const { return false; }
- bool shouldWalkTypesOfTypeLocs() const { return false; }
+ public:
+ BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) {
+ ShouldVisitTemplateInstantiations = false;
+ ShouldWalkTypesOfTypeLocs = false;
+ }
- bool TraverseStmt(Stmt *S) {
- PMap.reset(new ParentMap(S));
- ObjCMigrator(Consumer, *PMap).TraverseStmt(S);
- return true;
- }
-};
+ bool TraverseStmt(Stmt *S) override {
+ PMap.reset(new ParentMap(S));
+ ObjCMigrator(Consumer, *PMap).TraverseStmt(S);
+ return true;
+ }
+ };
} // end anonymous namespace
void ObjCMigrateASTConsumer::migrateDecl(Decl *D) {
@@ -1672,12 +1673,14 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation(
}
namespace {
-class SuperInitChecker : public RecursiveASTVisitor<SuperInitChecker> {
+class SuperInitChecker : public DynamicRecursiveASTVisitor {
public:
- bool shouldVisitTemplateInstantiations() const { return false; }
- bool shouldWalkTypesOfTypeLocs() const { return false; }
+ SuperInitChecker() {
+ ShouldVisitTemplateInstantiations = false;
+ ShouldWalkTypesOfTypeLocs = false;
+ }
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
+ bool VisitObjCMessageExpr(ObjCMessageExpr *E) override {
if (E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
if (E->getMethodFamily() == OMF_init)
return false;
diff --git a/clang/lib/ARCMigrate/TransAPIUses.cpp b/clang/lib/ARCMigrate/TransAPIUses.cpp
index 8f5d4f4bde06ca..7c397c609b3abe 100644
--- a/clang/lib/ARCMigrate/TransAPIUses.cpp
+++ b/clang/lib/ARCMigrate/TransAPIUses.cpp
@@ -16,9 +16,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Sema/SemaDiagnostic.h"
using namespace clang;
@@ -27,7 +28,7 @@ using namespace trans;
namespace {
-class APIChecker : public RecursiveASTVisitor<APIChecker> {
+class APIChecker : public DynamicRecursiveASTVisitor {
MigrationPass &Pass;
Selector getReturnValueSel, setReturnValueSel;
@@ -51,7 +52,7 @@ class APIChecker : public RecursiveASTVisitor<APIChecker> {
zoneSel = sels.getNullarySelector(&ids.get("zone"));
}
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
+ bool VisitObjCMessageExpr(ObjCMessageExpr *E) override {
// NSInvocation.
if (E->isInstanceMessage() &&
E->getReceiverInterface() &&
diff --git a/clang/lib/ARCMigrate/TransARCAssign.cpp b/clang/lib/ARCMigrate/TransARCAssign.cpp
index d1d5b9e014b17a..23d03e371dda8c 100644
--- a/clang/lib/ARCMigrate/TransARCAssign.cpp
+++ b/clang/lib/ARCMigrate/TransARCAssign.cpp
@@ -20,9 +20,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Sema/SemaDiagnostic.h"
using namespace clang;
@@ -31,14 +32,14 @@ using namespace trans;
namespace {
-class ARCAssignChecker : public RecursiveASTVisitor<ARCAssignChecker> {
+class ARCAssignChecker : public DynamicRecursiveASTVisitor {
MigrationPass &Pass;
llvm::DenseSet<VarDecl *> ModifiedVars;
public:
ARCAssignChecker(MigrationPass &pass) : Pass(pass) { }
- bool VisitBinaryOperator(BinaryOperator *Exp) {
+ bool VisitBinaryOperator(BinaryOperator *Exp) override {
if (Exp->getType()->isDependentType())
return true;
diff --git a/clang/lib/ARCMigrate/TransAutoreleasePool.cpp b/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
index 6d501228e712b2..d64d5d16754a43 100644
--- a/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
+++ b/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
@@ -26,9 +26,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Sema/SemaDiagnostic.h"
#include <map>
@@ -39,7 +40,7 @@ using namespace trans;
namespace {
-class ReleaseCollector : public RecursiveASTVisitor<ReleaseCollector> {
+class ReleaseCollector : public DynamicRecursiveASTVisitor {
Decl *Dcl;
SmallVectorImpl<ObjCMessageExpr *> &Releases;
@@ -47,7 +48,7 @@ class ReleaseCollector : public RecursiveASTVisitor<ReleaseCollector> {
ReleaseCollector(Decl *D, SmallVectorImpl<ObjCMessageExpr *> &releases)
: Dcl(D), Releases(releases) { }
- bool VisitObjCMessageExpr(ObjCMessageExpr *E) {
+ bool VisitObjCMessageExpr(ObjCMessageExpr *E) override {
if (!E->isInstanceMessage())
return true;
if (E->getMethodFamily() != OMF_release)
@@ -60,27 +61,32 @@ class ReleaseCollector : public RecursiveASTVisitor<ReleaseCollector> {
return true;
}
};
-
}
namespace {
-class AutoreleasePoolRewriter
- : public RecursiveASTVisitor<AutoreleasePoolRewriter> {
+class AutoreleasePoolRewriter : public BodyTransform {
+ bool TraversingBody = false;
+
public:
AutoreleasePoolRewriter(MigrationPass &pass)
- : Body(nullptr), Pass(pass) {
+ : BodyTransform(pass), Body(nullptr) {
PoolII = &pass.Ctx.Idents.get("NSAutoreleasePool");
DrainSel = pass.Ctx.Selectors.getNullarySelector(
&pass.Ctx.Idents.get("drain"));
}
- void transformBody(Stmt *body, Decl *ParentD) {
+ bool TraverseStmt(Stmt *body) override {
+ if (TraversingBody)
+ return BodyTransform::TraverseStmt(body);
+
+ llvm::SaveAndRestore Restore{TraversingBody, true};
Body = body;
- TraverseStmt(body);
+ BodyTransform::TraverseStmt(body);
+ return true;
}
- ~AutoreleasePoolRewriter() {
+ ~AutoreleasePoolRewriter() override {
SmallVector<VarDecl *, 8> VarsToHandle;
for (std::map<VarDecl *, PoolVarInfo>::iterator
@@ -160,7 +166,7 @@ class AutoreleasePoolRewriter
}
}
- bool VisitCompoundStmt(CompoundStmt *S) {
+ bool VisitCompoundStmt(CompoundStmt *S) override {
SmallVector<PoolScope, 4> Scopes;
for (Stmt::child_iterator
@@ -245,7 +251,7 @@ class AutoreleasePoolRewriter
}
};
- class NameReferenceChecker : public RecursiveASTVisitor<NameReferenceChecker>{
+ class NameReferenceChecker : public DynamicRecursiveASTVisitor {
ASTContext &Ctx;
SourceRange ScopeRange;
SourceLocation &referenceLoc, &declarationLoc;
@@ -260,15 +266,15 @@ class AutoreleasePoolRewriter
(*scope.End)->getBeginLoc());
}
- bool VisitDeclRefExpr(DeclRefExpr *E) {
+ bool VisitDeclRefExpr(DeclRefExpr *E) override {
return checkRef(E->getLocation(), E->getDecl()->getLocation());
}
- bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
+ bool VisitTypedefTypeLoc(TypedefTypeLoc TL) override {
return checkRef(TL.getBeginLoc(), TL.getTypedefNameDecl()->getLocation());
}
- bool VisitTagTypeLoc(TagTypeLoc TL) {
+ bool VisitTagTypeLoc(TagTypeLoc TL) override {
return checkRef(TL.getBeginLoc(), TL.getDecl()->getLocation());
}
@@ -411,7 +417,6 @@ class AutoreleasePoolRewriter
}
Stmt *Body;
- MigrationPass &Pass;
IdentifierInfo *PoolII;
Selector DrainSel;
@@ -430,6 +435,6 @@ class AutoreleasePoolRewriter
} // anonymous namespace
void trans::rewriteAutoreleasePool(MigrationPass &pass) {
- BodyTransform<AutoreleasePoolRewriter> trans(pass);
+ AutoreleasePoolRewriter trans(pass);
trans.TraverseDecl(pass.Ctx.getTranslationUnitDecl());
}
diff --git a/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp b/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp
index 1e4db33135b6a1..9c8869ebc89084 100644
--- a/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp
+++ b/clang/lib/ARCMigrate/TransBlockObjCVariable.cpp
@@ -24,10 +24,11 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
using namespace clang;
@@ -36,18 +37,16 @@ using namespace trans;
namespace {
-class RootBlockObjCVarRewriter :
- public RecursiveASTVisitor<RootBlockObjCVarRewriter> {
+class RootBlockObjCVarRewriter : public DynamicRecursiveASTVisitor {
llvm::DenseSet<VarDecl *> &VarsToChange;
- class BlockVarChecker : public RecursiveASTVisitor<BlockVarChecker> {
+ class BlockVarChecker : public DynamicRecursiveASTVisitor {
VarDecl *Var;
- typedef RecursiveASTVisitor<BlockVarChecker> base;
public:
BlockVarChecker(VarDecl *var) : Var(var) { }
- bool TraverseImplicitCastExpr(ImplicitCastExpr *castE) {
+ bool TraverseImplicitCastExpr(ImplicitCastExpr *castE) override {
if (DeclRefExpr *
ref = dyn_cast<DeclRefExpr>(castE->getSubExpr())) {
if (ref->getDecl() == Var) {
@@ -59,10 +58,10 @@ class RootBlockObjCVarRewriter :
}
}
- return base::TraverseImplicitCastExpr(castE);
+ return DynamicRecursiveASTVisitor::TraverseImplicitCastExpr(castE);
}
- bool VisitDeclRefExpr(DeclRefExpr *E) {
+ bool VisitDeclRefExpr(DeclRefExpr *E) override {
if (E->getDecl() == Var)
return false; // The reference of the variable, and not just its value,
// is needed.
@@ -74,7 +73,7 @@ class RootBlockObjCVarRewriter :
RootBlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
: VarsToChange(VarsToChange) { }
- bool VisitBlockDecl(BlockDecl *block) {
+ bool VisitBlockDecl(BlockDecl *block) override {
SmallVector<VarDecl *, 4> BlockVars;
for (const auto &I : block->captures()) {
@@ -108,14 +107,14 @@ class RootBlockObjCVarRewriter :
}
};
-class BlockObjCVarRewriter : public RecursiveASTVisitor<BlockObjCVarRewriter> {
+class BlockObjCVarRewriter : public DynamicRecursiveASTVisitor {
llvm::DenseSet<VarDecl *> &VarsToChange;
public:
BlockObjCVarRewriter(llvm::DenseSet<VarDecl *> &VarsToChange)
: VarsToChange(VarsToChange) { }
- bool TraverseBlockDecl(BlockDecl *block) {
+ bool TraverseBlockDecl(BlockDecl *block) override {
RootBlockObjCVarRewriter(VarsToChange).TraverseDecl(block);
return true;
}
diff --git a/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp b/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
index e9c21b8106d7dd..ecbee51437cb6a 100644
--- a/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
+++ b/clang/lib/ARCMigrate/TransEmptyStatementsAndDealloc.cpp
@@ -18,9 +18,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/SourceManager.h"
@@ -143,14 +144,13 @@ class EmptyChecker : public StmtVisitor<EmptyChecker, bool> {
}
};
-class EmptyStatementsRemover :
- public RecursiveASTVisitor<EmptyStatementsRemover> {
+class EmptyStatementsRemover : public DynamicRecursiveASTVisitor {
MigrationPass &Pass;
public:
EmptyStatementsRemover(MigrationPass &pass) : Pass(pass) { }
- bool TraverseStmtExpr(StmtExpr *E) {
+ bool TraverseStmtExpr(StmtExpr *E) override {
CompoundStmt *S = E->getSubStmt();
for (CompoundStmt::body_iterator
I = S->body_begin(), E = S->body_end(); I != E; ++I) {
@@ -161,7 +161,7 @@ class EmptyStatementsRemover :
return true;
}
- bool VisitCompoundStmt(CompoundStmt *S) {
+ bool VisitCompoundStmt(CompoundStmt *S) override {
for (auto *I : S->body())
check(I);
return true;
diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp
index 85e3fe77660b5c..1fbb5b896a0c23 100644
--- a/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp
@@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "clang/Sema/SemaDiagnostic.h"
@@ -23,26 +24,24 @@ using namespace trans;
namespace {
/// Collects all the places where GC attributes __strong/__weak occur.
-class GCAttrsCollector : public RecursiveASTVisitor<GCAttrsCollector> {
+class GCAttrsCollector : public DynamicRecursiveASTVisitor {
MigrationContext &MigrateCtx;
bool FullyMigratable;
std::vector<ObjCPropertyDecl *> &AllProps;
- typedef RecursiveASTVisitor<GCAttrsCollector> base;
public:
GCAttrsCollector(MigrationContext &ctx,
std::vector<ObjCPropertyDecl *> &AllProps)
- : MigrateCtx(ctx), FullyMigratable(false),
- AllProps(AllProps) { }
-
- bool shouldWalkTypesOfTypeLocs() const { return false; }
+ : MigrateCtx(ctx), FullyMigratable(false), AllProps(AllProps) {
+ ShouldWalkTypesOfTypeLocs = false;
+ }
- bool VisitAttributedTypeLoc(AttributedTypeLoc TL) {
+ bool VisitAttributedTypeLoc(AttributedTypeLoc TL) override {
handleAttr(TL);
return true;
}
- bool TraverseDecl(Decl *D) {
+ bool TraverseDecl(Decl *D) override {
if (!D || D->isImplicit())
return true;
@@ -54,7 +53,7 @@ class GCAttrsCollector : public RecursiveASTVisitor<GCAttrsCollector> {
} else if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
lookForAttribute(DD, DD->getTypeSourceInfo());
}
- return base::TraverseDecl(D);
+ return DynamicRecursiveASTVisitor::TraverseDecl(D);
}
void lookForAttribute(Decl *D, TypeSourceInfo *TInfo) {
diff --git a/clang/lib/ARCMigrate/TransGCCalls.cpp b/clang/lib/ARCMigrate/TransGCCalls.cpp
index 43233e2d0b456a..c2717dd1a72517 100644
--- a/clang/lib/ARCMigrate/TransGCCalls.cpp
+++ b/clang/lib/ARCMigrate/TransGCCalls.cpp
@@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//
-#include "Transforms.h"
#include "Internals.h"
+#include "Transforms.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Sema/SemaDiagnostic.h"
using namespace clang;
@@ -17,8 +18,7 @@ using namespace trans;
namespace {
-class GCCollectableCallsChecker :
- public RecursiveASTVisitor<GCCollectableCallsChecker> {
+class GCCollectableCallsChecker : public DynamicRecursiveASTVisitor {
MigrationContext &MigrateCtx;
IdentifierInfo *NSMakeCollectableII;
IdentifierInfo *CFMakeCollectableII;
@@ -29,11 +29,10 @@ class GCCollectableCallsChecker :
IdentifierTable &Ids = MigrateCtx.Pass.Ctx.Idents;
NSMakeCollectableII = &Ids.get("NSMakeCollectable");
CFMakeCollectableII = &Ids.get("CFMakeCollectable");
+ ShouldWalkTypesOfTypeLocs = false;
}
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
- bool VisitCallExpr(CallExpr *E) {
+ bool VisitCallExpr(CallExpr *E) override {
TransformActions &TA = MigrateCtx.Pass.TA;
if (MigrateCtx.isGCOwnedNonObjC(E->getType())) {
diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp
index 6d1d950821a07c..ee62ae41dd5f05 100644
--- a/clang/lib/ARCMigrate/TransProperties.cpp
+++ b/clang/lib/ARCMigrate/TransPropert...
[truncated]
|
@rjmccall do we still need ARC Migrate (my understanding was that this was a transitional tool)? I'm mostly wondering if this is something that can be pulled out of Clang at this point. |
@rjmccall ping |
Apple actually removed this migrator from Xcode 16. As far as Apple is concerned, this is now dead code, and we intend to open a PR to remove it (but thank you for the prompt!). |
Alright, in that case, I’ll close this and go ahead and open a PR to remove it myself while I’m at it. |
@rjmccall Actually, any idea when that might happen? If not, I can take a look at that too (the only thing is I might miss a few things that we could remove because I’m not really familiar w/ ARCMT). |
This pr migrates AST visitors in
ARCMigrate
to useDynamicRecursiveASTVisitor
.This is part of an ongoing refactor. For more context, see #110040, #93462.
Most of the visitors were fairly simple to migrate, but one that I wasn’t fully able to untangle was
BodyTransform
: For three of its uses, I’ve had to introduce a fairly uglybool
, and the last one (UnbridgedCastRewriter
) simply breaks if I try to refactor it in the same way as the other three (as in, one of the tests keeps failing, and I have no idea what to do about it...). I candidly am not really sure what the problem is w/ that one—it also doesn’t help that I have no understanding whatsoever of ARCMigrate nor of Objective-C.If you think the way I went about dealing w/
BodyTransform
is too janky, I can revert those 4 visitors again—most of the other visitors can still be migrated just fine and aren’t affected by that.