@@ -363,7 +363,6 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
363
363
364
364
std::vector<ConversionFunctionInfo> HelperFuncInfo;
365
365
SourceLoc FileEndLoc;
366
- llvm::StringSet<> OverridingRemoveNames;
367
366
368
367
// / For a given expression, check whether the type of this expression is
369
368
// / name alias type, and the name alias type is known to change to raw
@@ -386,8 +385,7 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
386
385
APIDiffMigratorPass (EditorAdapter &Editor, SourceFile *SF,
387
386
const MigratorOptions &Opts):
388
387
ASTMigratorPass (Editor, SF, Opts), DiffStore(Diags),
389
- FileEndLoc (SM.getRangeForBuffer(BufferID).getEnd()),
390
- OverridingRemoveNames (funcNamesForOverrideRemoval()) {}
388
+ FileEndLoc (SM.getRangeForBuffer(BufferID).getEnd()) {}
391
389
392
390
~APIDiffMigratorPass () {
393
391
Editor.disableCache ();
@@ -1292,92 +1290,6 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
1292
1290
}
1293
1291
}
1294
1292
1295
- llvm::StringSet<> funcNamesForOverrideRemoval () {
1296
- llvm::StringSet<> Results;
1297
- Results.insert (" c:objc(cs)NSObject(im)application:delegateHandlesKey:" );
1298
- Results.insert (" c:objc(cs)NSObject(im)changeColor:" );
1299
- Results.insert (" c:objc(cs)NSObject(im)controlTextDidBeginEditing:" );
1300
- Results.insert (" c:objc(cs)NSObject(im)controlTextDidEndEditing:" );
1301
- Results.insert (" c:objc(cs)NSObject(im)controlTextDidChange:" );
1302
- Results.insert (" c:objc(cs)NSObject(im)changeFont:" );
1303
- Results.insert (" c:objc(cs)NSObject(im)validModesForFontPanel:" );
1304
- Results.insert (" c:objc(cs)NSObject(im)discardEditing" );
1305
- Results.insert (" c:objc(cs)NSObject(im)commitEditing" );
1306
- Results.insert (" c:objc(cs)NSObject(im)commitEditingWithDelegate:didCommitSelector:contextInfo:" );
1307
- Results.insert (" c:objc(cs)NSObject(im)commitEditingAndReturnError:" );
1308
- Results.insert (" c:objc(cs)NSObject(im)objectDidBeginEditing:" );
1309
- Results.insert (" c:objc(cs)NSObject(im)objectDidEndEditing:" );
1310
- Results.insert (" c:objc(cs)NSObject(im)validateMenuItem:" );
1311
- Results.insert (" c:objc(cs)NSObject(im)pasteboard:provideDataForType:" );
1312
- Results.insert (" c:objc(cs)NSObject(im)pasteboardChangedOwner:" );
1313
- Results.insert (" c:objc(cs)NSObject(im)validateToolbarItem:" );
1314
- Results.insert (" c:objc(cs)NSObject(im)layer:shouldInheritContentsScale:fromWindow:" );
1315
- Results.insert (" c:objc(cs)NSObject(im)view:stringForToolTip:point:userData:" );
1316
- return Results;
1317
- }
1318
-
1319
- SourceLoc shouldRemoveOverride (AbstractFunctionDecl *AFD) {
1320
- if (AFD->getKind () != DeclKind::Func)
1321
- return SourceLoc ();
1322
- SourceLoc OverrideLoc;
1323
-
1324
- // Get the location of override keyword.
1325
- if (auto *Override = AFD->getAttrs ().getAttribute <OverrideAttr>()) {
1326
- if (Override->getRange ().isValid ()) {
1327
- OverrideLoc = Override->getLocation ();
1328
- }
1329
- }
1330
- if (OverrideLoc.isInvalid ())
1331
- return SourceLoc ();
1332
- auto *OD = AFD->getOverriddenDecl ();
1333
- llvm::SmallString<64 > Buffer;
1334
- llvm::raw_svector_ostream OS (Buffer);
1335
- if (swift::ide::printDeclUSR (OD, OS))
1336
- return SourceLoc ();
1337
- return OverridingRemoveNames.find (OS.str ()) == OverridingRemoveNames.end () ?
1338
- SourceLoc () : OverrideLoc;
1339
- }
1340
-
1341
- struct SuperRemoval : public ASTWalker {
1342
- EditorAdapter &Editor;
1343
- llvm::StringSet<> &USRs;
1344
- SuperRemoval (EditorAdapter &Editor, llvm::StringSet<> &USRs):
1345
- Editor (Editor), USRs(USRs) {}
1346
- bool isSuperExpr (Expr *E) {
1347
- if (E->isImplicit ())
1348
- return false ;
1349
- // Check if the expression is super.foo().
1350
- if (auto *CE = dyn_cast<CallExpr>(E)) {
1351
- if (auto *DSC = dyn_cast<DotSyntaxCallExpr>(CE->getFn ())) {
1352
- if (DSC->getBase ()->getKind () != ExprKind::SuperRef)
1353
- return false ;
1354
- llvm::SmallString<64 > Buffer;
1355
- llvm::raw_svector_ostream OS (Buffer);
1356
- auto *RD = DSC->getFn ()->getReferencedDecl ().getDecl ();
1357
- if (swift::ide::printDeclUSR (RD, OS))
1358
- return false ;
1359
- return USRs.find (OS.str ()) != USRs.end ();
1360
- }
1361
- }
1362
- // We should handle try super.foo() too.
1363
- if (auto *TE = dyn_cast<AnyTryExpr>(E)) {
1364
- return isSuperExpr (TE->getSubExpr ());
1365
- }
1366
- return false ;
1367
- }
1368
- std::pair<bool , Stmt*> walkToStmtPre (Stmt *S) override {
1369
- if (auto *BS = dyn_cast<BraceStmt>(S)) {
1370
- for (auto Ele: BS->getElements ()) {
1371
- if (Ele.is <Expr*>() && isSuperExpr (Ele.get <Expr*>())) {
1372
- Editor.remove (Ele.getSourceRange ());
1373
- }
1374
- }
1375
- }
1376
- // We only handle top-level expressions, so avoid visiting further.
1377
- return {false , S};
1378
- }
1379
- };
1380
-
1381
1293
bool walkToDeclPre (Decl *D, CharSourceRange Range) override {
1382
1294
if (D->isImplicit ())
1383
1295
return true ;
@@ -1393,14 +1305,6 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
1393
1305
handleLocalParameterBridge (AFD, DiffItem);
1394
1306
}
1395
1307
}
1396
- auto OverrideLoc = shouldRemoveOverride (AFD);
1397
- if (OverrideLoc.isValid ()) {
1398
- // Remove override keyword.
1399
- Editor.remove (OverrideLoc);
1400
- // Remove super-dot call.
1401
- SuperRemoval Removal (Editor, OverridingRemoveNames);
1402
- D->walk (Removal);
1403
- }
1404
1308
}
1405
1309
return true ;
1406
1310
}
0 commit comments