@@ -347,9 +347,6 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
347347 Editor.replace (Range, RepText);
348348 return true ;
349349 }
350- if (updateStringRepresentableDeclRef (Item, Range)) {
351- return true ;
352- }
353350 }
354351 return true ;
355352 }
@@ -683,20 +680,30 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
683680 auto *RD = getReferencedDecl (Reference);
684681 if (!RD)
685682 return false ;
683+ std::string Func;
684+ std::string Rename;
686685 for (auto *Item: getRelatedDiffItems (RD)) {
687- if (auto *CI = dyn_cast<CommonDiffItem>(Item)) {
686+ if (isSimpleReplacement (Item, Rename)) {
687+ } else if (auto *CI = dyn_cast<CommonDiffItem>(Item)) {
688688 if (CI->isStringRepresentableChange () &&
689689 CI->NodeKind == SDKNodeKind::DeclVar) {
690690 SmallString<256 > Buffer;
691- auto Func = insertHelperFunction (CI->DiffKind , CI->RightComment ,
692- Buffer, FromString);
693- Editor.insert (WrapperTarget->getStartLoc (), (Twine (Func) + " (" ).str ());
694- Editor.insertAfterToken (WrapperTarget->getEndLoc (), " )" );
695- return true ;
691+ Func = insertHelperFunction (CI->DiffKind , CI->RightComment , Buffer,
692+ FromString);
696693 }
697694 }
698695 }
699- return false ;
696+ if (Func.empty ())
697+ return false ;
698+
699+ Editor.insert (WrapperTarget->getStartLoc (), (Twine (Func) + " (" ).str ());
700+ Editor.insertAfterToken (WrapperTarget->getEndLoc (), " )" );
701+ if (!Rename.empty ()) {
702+ auto Range = CharSourceRange (SM, Reference->getStartLoc (),
703+ Lexer::getLocForEndOfToken (SM, Reference->getEndLoc ()));
704+ Editor.replace (Range, Rename);
705+ }
706+ return true ;
700707 }
701708
702709 bool handleAssignDestMigration (Expr *E) {
@@ -827,7 +834,9 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
827834 bool walkToExprPre (Expr *E) override {
828835 if (handleQualifiedReplacement (E))
829836 return false ;
830- if (handleAssignDestMigration (E) || handleAttributeReference (E))
837+ if (handleAssignDestMigration (E))
838+ return false ;
839+ if (handleAttributeReference (E))
831840 return false ;
832841 if (auto *CE = dyn_cast<CallExpr>(E)) {
833842 auto Fn = CE->getFn ();
0 commit comments