Skip to content

Consolidate native diagnostic formatting and diagnostic parsing helpers #8128

@doublemover

Description

@doublemover

Parent inventory: #8108

Objective

Consolidate duplicated native diagnostic construction, normalization-adjacent helpers, and diagnostic coordinate parsing.

Shared Module Specification

  • Extend native/objc3c/src/diag/objc3_diag_utils.* or add a dependency-neutral diagnostic helper module if that avoids cycles.
  • Expose one MakeDiag-equivalent formatter preserving exact line:column: message [CODE] semantics.
  • Expose diagnostic code/coordinate parsing helpers used by grammar/source precision checks.
  • Keep parser/sema/lex dependency direction clean.
  • Prefer simple unsigned scanning for diagnostic coordinate parsing over exception-heavy numeric parsing.

Migration Checklist

  • Migrate duplicate MakeDiag implementations where dependency direction allows.
  • Migrate duplicated diagnostic coordinate parsing helpers.
  • Migrate FlattenStageDiagnostics only if the shared diagnostic utility is the correct owner.
  • Preserve exact diagnostic text and sorting behavior.
  • Update CMake target dependencies if a source file moves across libraries.

Complete Replacement Inventory

  • MakeDiag - 6 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/lex/objc3_lexer.cpp:54
    • native/objc3c/src/parse/objc3_parse_support.cpp:109
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:11077
    • native/objc3c/src/sema/objc3_pure_contract.cpp:10
    • native/objc3c/src/sema/objc3_sema_pass_manager.cpp:36
    • native/objc3c/src/sema/objc3_semantic_passes.cpp:16
  • FlattenStageDiagnostics - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/io/objc3_diagnostics_artifacts.cpp:56
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:11083
  • StartsWith - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/parse/objc3_diagnostic_grammar_hooks_core_feature.cpp:9
    • native/objc3c/src/parse/objc3_diagnostic_source_precision_scaffold.cpp:8
  • TryParseUnsignedSegment - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/parse/objc3_diagnostic_grammar_hooks_core_feature.cpp:14
    • native/objc3c/src/parse/objc3_diagnostic_source_precision_scaffold.cpp:13
  • TryParseDiagnosticCoordinateAndCode - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/parse/objc3_diagnostic_grammar_hooks_core_feature.cpp:34
    • native/objc3c/src/parse/objc3_diagnostic_source_precision_scaffold.cpp:34

Performance And Reliability Requirements

  • Keep helper code small, dependency-light, and fast enough for normal development feedback.
  • Add focused tests for edge cases before broad migration.
  • Preserve existing output schemas and public behavior unless an intentional bug fix is validated.
  • Keep production helpers separated from test-only helpers.
  • Do not use tmp/ as durable source-of-truth; generated temporary files are allowed only as transient command inputs.

Fast Tests

  • Run diagnostic utility tests.
  • Run lexer/parser/sema diagnostic tests affected by MakeDiag changes.
  • Run native build.
  • Run focused frontend diagnostics checks.
  • Run git diff --check.

End-To-End Completion Criteria

  • Diagnostic formatting has one authoritative implementation where dependency direction permits.
  • Diagnostic coordinate parsing has one authoritative implementation.
  • Diagnostic output remains byte-for-byte compatible except for intentional validated bug fixes.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions