Files
llvm-project/clang/test/Tooling/serialize-diagnostics.cpp
mitchell 174aaacf97 [Clang] Fix assertion failure in SDiagsWriter when finish() is not called (#181712)
When `--serialize-diagnostics` is used, `SDiagsWriter` enters bitstream
blocks during its initialization. They are expected to be exited in the
`finish()` method.

However in LibTooling based tools (like `clang-tidy` or `clang-check`),
if a user provides an invalid command-line argument, the driver detects
the error and prepares for an early exit. The exit path leads directly
to destruction, skipping the call to `finish()` that would normally
occur in the main logic. Then the assertion detects this block imbalance
and triggers a crash.

As of AI Usage: Gemini 3 was used to rephrase part of the PR description
Closes https://github.com/llvm/llvm-project/issues/140433
2026-02-24 00:52:04 +08:00

8 lines
187 B
C++

// RUN: clang-check %s -- -Wdoes-not-exist --serialize-diagnostics /dev/null 2>&1 | FileCheck %s
// CHECK: warning: unknown warning option '-Wdoes-not-exist'
int main() {
return 0;
}