Skip to content

Commit aafc2a3

Browse files
committed
Better idiom for sometimes RAII.
1 parent bb131fb commit aafc2a3

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,10 +1219,9 @@ static bool performCompileStepsPostSILGen(
12191219
SILOptions &SILOpts = Invocation.getSILOptions();
12201220
IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
12211221

1222-
BufferIndirectlyCausingDiagnosticRAII ricd(
1223-
Context.Diags, MSF.is<SourceFile *>()
1224-
? MSF.dyn_cast<SourceFile *>()->getFilename()
1225-
: "");
1222+
Optional<BufferIndirectlyCausingDiagnosticRAII> ricd;
1223+
if (auto *SF = MSF.dyn_cast<SourceFile *>())
1224+
ricd.emplace(Context.Diags, SF->getFilename());
12261225

12271226
if (Stats)
12281227
countStatsPostSILGen(*Stats, *SM);

0 commit comments

Comments
 (0)