Skip to content

Commit bf524c4

Browse files
committed
[sil-llvm-gen] Run Sema before we attempt to emit IR.
(cherry picked from commit 3a96e99)
1 parent 2e7c74c commit bf524c4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/DriverTool/sil_llvm_gen_main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,15 @@ int sil_llvm_gen_main(ArrayRef<const char *> argv, void *MainAddr) {
469469
desc.out = &outFile->getOS();
470470

471471
if (options.OutputKind == IRGenOutputKind::LLVMAssemblyBeforeOptimization) {
472+
// We need to perform Sema here since IRGenRequest itself does not perform
473+
// Sema (unlike OptimizedIRRequest).
474+
CI.performSema();
475+
476+
// If Sema produced an error, exit early.
477+
bool HadError = CI.getASTContext().hadError();
478+
if (HadError)
479+
exit(-1);
480+
472481
auto generatedMod = evaluateOrFatal(eval, IRGenRequest{desc});
473482
if (!generatedMod)
474483
return 1;

0 commit comments

Comments
 (0)