Skip to content

llvm prompts: stop reporting untouched pre-existing defects and errorNYI() null returns #975

Done

Description

@sendaoYan

The LLVM profile reports two recurring false positives on clang patches; both
come from projects/llvm/prompts/false-positive-guide.md and both survive
re-runs.

  1. Pre-existing defects in untouched functions are raised as High.
    Rule 8 currently says to report them with "preexisting": true, which
    brings them into the severity summary.
  2. cgm.errorNYI() + return {} / return nullptr is raised as a null
    dereference. The diagnostic already fails the compilation and stops code
    generation after the current statement; returning a null mlir::Value is
    the established pattern in CIRGenExprScalar.cpp and other CodeGen files.

These are LLVM-convention judgement errors, so the fix belongs in the prompt
bundle, not in Rust-side filtering.

Reproduction

Proposed change

Rewrite rule 8 so a defect in a function the patch does not modify is never a
finding of this review, and add rule 9:

8. **Existing upstream behaviour**: a defect that predates the patch is not a
   regression of this patch, so do not report it as one. Do not drop it either,
   but keep it out of the severity summary: mention it in a short
   "pre-existing, out of scope" note. If the patch does not modify the function
   at all, it is never a finding of this review.
9. **`errorNYI()` and other fatal diagnostics**: clang's CIRGen and CodeGen
   use `cgm.errorNYI()` (or `error()`) for paths that are deliberately not
   implemented; the diagnostic marks the compilation as failed and code
   generation stops after the current statement. Returning a null
   `mlir::Value` or `nullptr` from such a path is the established convention in
   the same file (see `CIRGenExprScalar.cpp` around lines 144 and 195). A
   report that "the null value propagates to a caller and is dereferenced" is
   not a valid finding unless you can point at a caller that continues code
   generation after such a diagnostic. Do not report it.

Measured effect

Same commit, model, and base:

prompt Critical High Low notes
shipped 0 2 2 both false positives present
+ rules 8/9 0 2 1 untouched-defect FP gone; errorNYI FP remains
+ rule 9 anchors 0 1 1 both false positives gone

The remaining High is a real gap in the non-atomic -- path (tracked in
#247673), so leaving it reported is correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions