llvm / llvm/llvm-project

[mlir] "expected" diagnostics are checked even when `-verify-diagnostics` flag is not used

Open Beginner friendly
#222,689 1 comment 0 reactions 0 assignees View on GitHub
mlir
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Commit: 2e2c316fd5d7e8cff94703992928d5882d00478e

Input:
```mlir
// expected-error @unknown {{an error that is never produced}}
module {}
```

Command:
`build/bin/mlir-opt input.mlir`

Actual output:
```
module {
}

:0: error: expected error "an error that is never produced" was not produced
```

Expected output:
```
module {
}
```

Relevant code:
https://github.com/llvm/llvm-project/blob/847fb5cfde68fdea490171bc24087ebb0cd90738/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp#L777-L796

The `SourceMgrDiagnosticVerifierHandler` is created unconditionally rather than guarded by `config.shouldVerifyDiagnostics()` and its destructor calls `verify()` which results in unsatisfied "expected" declarations being reported even when `config.shouldVerifyDiagnostics()` is false.

Contributor guide

Open the contributing guide

Research direction

Start in mlir/lib/Tools/mlir-opt/MlirOptMain.cpp around lines 777-796, where the diagnostic verifier handler is created, and reproduce the issue with build/bin/mlir-opt input.mlir using the supplied MLIR input. Repeat with -verify-diagnostics. Done when the unsatisfied expected diagnostic is reported only when that flag is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.