@@ -1058,6 +1058,10 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
1058
1058
subInstanceMap = new CompilerArgInstanceCacheMap;
1059
1059
localSubInstanceMap = true ;
1060
1060
}
1061
+ SWIFT_DEFER {
1062
+ if (localSubInstanceMap)
1063
+ delete subInstanceMap;
1064
+ };
1061
1065
1062
1066
auto &diags = invocationInstance.getDiags ();
1063
1067
ForwardingDiagnosticConsumer FDC (invocationInstance.getDiags ());
@@ -1094,16 +1098,12 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
1094
1098
if (subInvoke.parseArgs (args, diags)) {
1095
1099
invocationInstance.getDiags ().diagnose (
1096
1100
SourceLoc (), diag::scanner_arguments_invalid, entry.arguments );
1097
- if (localSubInstanceMap)
1098
- delete subInstanceMap;
1099
1101
return true ;
1100
1102
}
1101
1103
std::string InstanceSetupError;
1102
1104
if (newInstance->setup (subInvoke, InstanceSetupError)) {
1103
1105
invocationInstance.getDiags ().diagnose (
1104
1106
SourceLoc (), diag::scanner_arguments_invalid, entry.arguments );
1105
- if (localSubInstanceMap)
1106
- delete subInstanceMap;
1107
1107
return true ;
1108
1108
}
1109
1109
auto mainModuleName = newInstance->getMainModule ()->getNameStr ();
@@ -1122,8 +1122,6 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
1122
1122
scanningAction (entry, *pInstance, *pCache);
1123
1123
}
1124
1124
1125
- if (localSubInstanceMap)
1126
- delete subInstanceMap;
1127
1125
return false ;
1128
1126
}
1129
1127
0 commit comments