[all-commits] [llvm/llvm-project] 76cb4c: [clang] Fix serialized diagnostics edge-cases
Jan Svoboda via All-commits
all-commits at lists.llvm.org
Wed Jan 26 02:22:57 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 76cb4cd074a6816f3801fd4a2bd8854597748239
https://github.com/llvm/llvm-project/commit/76cb4cd074a6816f3801fd4a2bd8854597748239
Author: Jan Svoboda <jan_svoboda at apple.com>
Date: 2022-01-26 (Wed, 26 Jan 2022)
Changed paths:
M clang/lib/Frontend/CompilerInstance.cpp
A clang/test/Misc/serialized-diags-emit-header-module-misconfig.c
A clang/test/Misc/serialized-diags-unknown-argument.c
A clang/test/Misc/serialized-diags-unknown-target.c
M clang/tools/driver/cc1_main.cpp
Log Message:
-----------
[clang] Fix serialized diagnostics edge-cases
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
More information about the All-commits
mailing list