|
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | 9 | #include "Transforms.h" |
10 | | -#include "clang/Analysis/RetainSummaryManager.h" |
11 | 10 | #include "clang/ARCMigrate/ARCMT.h" |
12 | 11 | #include "clang/ARCMigrate/ARCMTActions.h" |
13 | 12 | #include "clang/AST/ASTConsumer.h" |
14 | 13 | #include "clang/AST/ASTContext.h" |
15 | 14 | #include "clang/AST/Attr.h" |
| 15 | +#include "clang/AST/DynamicRecursiveASTVisitor.h" |
16 | 16 | #include "clang/AST/NSAPI.h" |
17 | 17 | #include "clang/AST/ParentMap.h" |
18 | | -#include "clang/AST/RecursiveASTVisitor.h" |
19 | 18 | #include "clang/Analysis/DomainSpecific/CocoaConventions.h" |
| 19 | +#include "clang/Analysis/RetainSummaryManager.h" |
20 | 20 | #include "clang/Basic/FileManager.h" |
21 | 21 | #include "clang/Edit/Commit.h" |
22 | 22 | #include "clang/Edit/EditedSource.h" |
@@ -309,67 +309,68 @@ namespace { |
309 | 309 | return true; |
310 | 310 | } |
311 | 311 |
|
312 | | -class ObjCMigrator : public RecursiveASTVisitor<ObjCMigrator> { |
313 | | - ObjCMigrateASTConsumer &Consumer; |
314 | | - ParentMap &PMap; |
315 | | - |
316 | | -public: |
317 | | - ObjCMigrator(ObjCMigrateASTConsumer &consumer, ParentMap &PMap) |
318 | | - : Consumer(consumer), PMap(PMap) { } |
319 | | - |
320 | | - bool shouldVisitTemplateInstantiations() const { return false; } |
321 | | - bool shouldWalkTypesOfTypeLocs() const { return false; } |
| 312 | + class ObjCMigrator : public DynamicRecursiveASTVisitor { |
| 313 | + ObjCMigrateASTConsumer &Consumer; |
| 314 | + ParentMap &PMap; |
322 | 315 |
|
323 | | - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { |
324 | | - if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) { |
325 | | - edit::Commit commit(*Consumer.Editor); |
326 | | - edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap); |
327 | | - Consumer.Editor->commit(commit); |
| 316 | + public: |
| 317 | + ObjCMigrator(ObjCMigrateASTConsumer &consumer, ParentMap &PMap) |
| 318 | + : Consumer(consumer), PMap(PMap) { |
| 319 | + ShouldVisitTemplateInstantiations = false; |
| 320 | + ShouldWalkTypesOfTypeLocs = false; |
328 | 321 | } |
329 | 322 |
|
330 | | - if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) { |
331 | | - edit::Commit commit(*Consumer.Editor); |
332 | | - edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit); |
333 | | - Consumer.Editor->commit(commit); |
334 | | - } |
| 323 | + bool VisitObjCMessageExpr(ObjCMessageExpr *E) override { |
| 324 | + if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) { |
| 325 | + edit::Commit commit(*Consumer.Editor); |
| 326 | + edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap); |
| 327 | + Consumer.Editor->commit(commit); |
| 328 | + } |
335 | 329 |
|
336 | | - if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_PropertyDotSyntax) { |
337 | | - edit::Commit commit(*Consumer.Editor); |
338 | | - rewriteToPropertyDotSyntax(E, Consumer.PP, *Consumer.NSAPIObj, |
339 | | - commit, &PMap); |
340 | | - Consumer.Editor->commit(commit); |
341 | | - } |
| 330 | + if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) { |
| 331 | + edit::Commit commit(*Consumer.Editor); |
| 332 | + edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit); |
| 333 | + Consumer.Editor->commit(commit); |
| 334 | + } |
342 | 335 |
|
343 | | - return true; |
344 | | - } |
| 336 | + if (Consumer.ASTMigrateActions & |
| 337 | + FrontendOptions::ObjCMT_PropertyDotSyntax) { |
| 338 | + edit::Commit commit(*Consumer.Editor); |
| 339 | + rewriteToPropertyDotSyntax(E, Consumer.PP, *Consumer.NSAPIObj, commit, |
| 340 | + &PMap); |
| 341 | + Consumer.Editor->commit(commit); |
| 342 | + } |
345 | 343 |
|
346 | | - bool TraverseObjCMessageExpr(ObjCMessageExpr *E) { |
347 | | - // Do depth first; we want to rewrite the subexpressions first so that if |
348 | | - // we have to move expressions we will move them already rewritten. |
349 | | - for (Stmt *SubStmt : E->children()) |
350 | | - if (!TraverseStmt(SubStmt)) |
351 | | - return false; |
| 344 | + return true; |
| 345 | + } |
352 | 346 |
|
353 | | - return WalkUpFromObjCMessageExpr(E); |
354 | | - } |
355 | | -}; |
| 347 | + bool TraverseObjCMessageExpr(ObjCMessageExpr *E) override { |
| 348 | + // Do depth first; we want to rewrite the subexpressions first so that if |
| 349 | + // we have to move expressions we will move them already rewritten. |
| 350 | + for (Stmt *SubStmt : E->children()) |
| 351 | + if (!TraverseStmt(SubStmt)) |
| 352 | + return false; |
356 | 353 |
|
357 | | -class BodyMigrator : public RecursiveASTVisitor<BodyMigrator> { |
358 | | - ObjCMigrateASTConsumer &Consumer; |
359 | | - std::unique_ptr<ParentMap> PMap; |
| 354 | + return WalkUpFromObjCMessageExpr(E); |
| 355 | + } |
| 356 | + }; |
360 | 357 |
|
361 | | -public: |
362 | | - BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) { } |
| 358 | + class BodyMigrator : public DynamicRecursiveASTVisitor { |
| 359 | + ObjCMigrateASTConsumer &Consumer; |
| 360 | + std::unique_ptr<ParentMap> PMap; |
363 | 361 |
|
364 | | - bool shouldVisitTemplateInstantiations() const { return false; } |
365 | | - bool shouldWalkTypesOfTypeLocs() const { return false; } |
| 362 | + public: |
| 363 | + BodyMigrator(ObjCMigrateASTConsumer &consumer) : Consumer(consumer) { |
| 364 | + ShouldVisitTemplateInstantiations = false; |
| 365 | + ShouldWalkTypesOfTypeLocs = false; |
| 366 | + } |
366 | 367 |
|
367 | | - bool TraverseStmt(Stmt *S) { |
368 | | - PMap.reset(new ParentMap(S)); |
369 | | - ObjCMigrator(Consumer, *PMap).TraverseStmt(S); |
370 | | - return true; |
371 | | - } |
372 | | -}; |
| 368 | + bool TraverseStmt(Stmt *S) override { |
| 369 | + PMap.reset(new ParentMap(S)); |
| 370 | + ObjCMigrator(Consumer, *PMap).TraverseStmt(S); |
| 371 | + return true; |
| 372 | + } |
| 373 | + }; |
373 | 374 | } // end anonymous namespace |
374 | 375 |
|
375 | 376 | void ObjCMigrateASTConsumer::migrateDecl(Decl *D) { |
@@ -1672,12 +1673,14 @@ void ObjCMigrateASTConsumer::migrateAddMethodAnnotation( |
1672 | 1673 | } |
1673 | 1674 |
|
1674 | 1675 | namespace { |
1675 | | -class SuperInitChecker : public RecursiveASTVisitor<SuperInitChecker> { |
| 1676 | +class SuperInitChecker : public DynamicRecursiveASTVisitor { |
1676 | 1677 | public: |
1677 | | - bool shouldVisitTemplateInstantiations() const { return false; } |
1678 | | - bool shouldWalkTypesOfTypeLocs() const { return false; } |
| 1678 | + SuperInitChecker() { |
| 1679 | + ShouldVisitTemplateInstantiations = false; |
| 1680 | + ShouldWalkTypesOfTypeLocs = false; |
| 1681 | + } |
1679 | 1682 |
|
1680 | | - bool VisitObjCMessageExpr(ObjCMessageExpr *E) { |
| 1683 | + bool VisitObjCMessageExpr(ObjCMessageExpr *E) override { |
1681 | 1684 | if (E->getReceiverKind() == ObjCMessageExpr::SuperInstance) { |
1682 | 1685 | if (E->getMethodFamily() == OMF_init) |
1683 | 1686 | return false; |
|
0 commit comments