mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 18:36:05 +00:00

The Clang frontend sometimes fails on the following assertion when launched with `-serialize-diagnostic-file <x>`: ``` Assertion failed: (BlockScope.empty() && CurAbbrevs.empty() && "Block imbalance"), function ~BitstreamWriter, file BitstreamWriter.h, line 125. ``` This was first noticed when passing an unknown command-line argument to `-cc1`. It turns out the `DiagnosticConsumer::finish()` function should be called as soon as processing of all source files ends, but there are some code paths where that doesn't happen: 1. when command line parsing fails in `cc1_main()`, 2. when `!Act.PrepareToExecute(*this)` or `!createTarget()` evaluate to `true` in `CompilerInstance::ExecuteAction` and the function returns early. This patch ensures `finish()` is called in all those code paths. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D118150
5 lines
198 B
C
5 lines
198 B
C
// RUN: rm -rf %t && mkdir %t
|
|
// RUN: not %clang_cc1 %s -unknown-argument -serialize-diagnostic-file %t/diag -o /dev/null 2>&1 | FileCheck %s
|
|
|
|
// CHECK: error: unknown argument: '-unknown-argument'
|