Skip to content

Consolidate native lexical predicates runtime-symbol predicates and misc helpers #8129

@doublemover

Description

@doublemover

Parent inventory: #8108

Objective

Hoist native helper duplicates that are not JSON or diagnostic formatting: lexical digit predicates, runtime dispatch symbol validation, parser/sema classification helpers, and small IO/string helpers.

Shared Module Specification

  • Place digit predicates in a parse/lex support boundary with no dependency cycle.
  • Make runtime dispatch symbol validation authoritative in lowering contract or a dependency-neutral support header used by both CLI and lowering.
  • Hoist MakeIdentifierSafeSuffix, ReadTextFile, ParseIrObjectBackend, ClassifyMethodFamilyFromSelector, and runtime metadata counters only after confirming semantics are identical.
  • Keep generated/readiness-surface helper duplication out of this issue unless the source is hand-authored and dependency direction is clear.

Migration Checklist

  • Migrate digit predicates and add byte/locale-independent tests.
  • Migrate runtime dispatch symbol predicates and prove CLI validation and lowering validation stay aligned.
  • Migrate miscellaneous helpers in small batches with focused tests.
  • Document intentionally local helpers when names match but semantics differ.
  • Update CMake target dependencies if helper ownership moves across libraries.

Complete Replacement Inventory

  • IsHexDigit - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/lex/objc3_lexer.cpp:20
    • native/objc3c/src/parse/objc3_parse_support.cpp:13
  • IsBinaryDigit - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/lex/objc3_lexer.cpp:24
    • native/objc3c/src/parse/objc3_parse_support.cpp:17
  • IsOctalDigit - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/lex/objc3_lexer.cpp:28
    • native/objc3c/src/parse/objc3_parse_support.cpp:21
  • IsDigitSeparator - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/lex/objc3_lexer.cpp:32
    • native/objc3c/src/parse/objc3_parse_support.cpp:25
  • IsRuntimeDispatchSymbolStart - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/driver/objc3_cli_options.cpp:14
    • native/objc3c/src/lower/objc3_lowering_contract.cpp:12
  • IsRuntimeDispatchSymbolBody - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/driver/objc3_cli_options.cpp:18
    • native/objc3c/src/lower/objc3_lowering_contract.cpp:16
  • IsValidRuntimeDispatchSymbol - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/driver/objc3_cli_options.cpp:22
    • native/objc3c/src/lower/objc3_lowering_contract.cpp:143
  • TypeName - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:225
    • native/objc3c/src/sema/objc3_semantic_passes.cpp:34
  • MakeIdentifierSafeSuffix - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/io/objc3_process.cpp:373
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:9148
  • ParseIrObjectBackend - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/driver/objc3_cli_options.cpp:34
    • native/objc3c/src/tools/objc3c_frontend_c_api_runner.cpp:68
  • ReadTextFile - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/libobjc3c_frontend/frontend_anchor.cpp:342
    • native/objc3c/src/pipeline/objc3_runtime_import_surface.cpp:285
  • ClassifyMethodFamilyFromSelector - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/parse/objc3_parser.cpp:207
    • native/objc3c/src/sema/objc3_semantic_passes.cpp:17033
  • CountRuntimeMetadataSourceRecordSetDeclarations - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:7605
    • native/objc3c/src/pipeline/objc3_runtime_import_surface.cpp:1732
  • CountRuntimeMetadataSourceRecordSetReferences - 2 definition(s)/local occurrence(s) to replace or explicitly document as intentionally local if semantics differ.
    • native/objc3c/src/pipeline/objc3_frontend_artifacts.cpp:7615
    • native/objc3c/src/pipeline/objc3_runtime_import_surface.cpp:1742

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 lexer/parser tests for digit predicates.
  • Run CLI/lowering tests for runtime dispatch symbol validation.
  • Run native build.
  • Run focused frontend/runtime import tests for metadata counter changes.
  • Run git diff --check.

End-To-End Completion Criteria

  • Each migrated helper has one authoritative production implementation.
  • No dependency cycle is introduced.
  • Callers with intentionally different semantics are documented rather than mechanically merged.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions