Skip to content

Commit 8f86bf5

Browse files
committed
Use SWIFT_DEFER
1 parent 3002fee commit 8f86bf5

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,10 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
10581058
subInstanceMap = new CompilerArgInstanceCacheMap;
10591059
localSubInstanceMap = true;
10601060
}
1061+
SWIFT_DEFER {
1062+
if (localSubInstanceMap)
1063+
delete subInstanceMap;
1064+
};
10611065

10621066
auto &diags = invocationInstance.getDiags();
10631067
ForwardingDiagnosticConsumer FDC(invocationInstance.getDiags());
@@ -1094,16 +1098,12 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
10941098
if (subInvoke.parseArgs(args, diags)) {
10951099
invocationInstance.getDiags().diagnose(
10961100
SourceLoc(), diag::scanner_arguments_invalid, entry.arguments);
1097-
if (localSubInstanceMap)
1098-
delete subInstanceMap;
10991101
return true;
11001102
}
11011103
std::string InstanceSetupError;
11021104
if (newInstance->setup(subInvoke, InstanceSetupError)) {
11031105
invocationInstance.getDiags().diagnose(
11041106
SourceLoc(), diag::scanner_arguments_invalid, entry.arguments);
1105-
if (localSubInstanceMap)
1106-
delete subInstanceMap;
11071107
return true;
11081108
}
11091109
auto mainModuleName = newInstance->getMainModule()->getNameStr();
@@ -1122,8 +1122,6 @@ forEachBatchEntry(CompilerInstance &invocationInstance,
11221122
scanningAction(entry, *pInstance, *pCache);
11231123
}
11241124

1125-
if (localSubInstanceMap)
1126-
delete subInstanceMap;
11271125
return false;
11281126
}
11291127

0 commit comments

Comments
 (0)