Repository navigation
Merged
Conversation
added 3 commits
October 23, 2026 05:03
libclang's GenericSelectionExpr (kind 122) was grouped with the
transparent wrappers and peeled to its last child, the default arm:
M*LIB's `m_string_init_set(s, "text")` (`_Generic((b)+0, char*:
m_string_init_set_cstr, const char *: m_string_init_set_cstr, default:
m_string_init_set)`) called the string_t overload with a C string, and
the upstream B+tree test faulted in its string contract at the first
emplace.
The selection follows C11 6.5.1.1. libclang names an association's type
only as a TypeRef child for a typedef name and not at all for a builtin
spelling, so the association list is read from the expression's text
through the macros that spell it (ci_preprocessed_text_for_cursor): the
controlling expression's canonical type after lvalue conversion, each
association's type name under one spelling for the integer synonyms
(`signed int` is `int`, `long int` is `long`), a typedef name resolved
through its TypeRef, the first match's expression, else the default's,
else refused loudly. M*LIB's hash dispatch, `_Generic(((void)0,(x)),
int32_t: (x), default: (int32_t){0})`, selects by type where the arms'
expressions share one. Fixture: generic_selection.
The text expander (ci_expand_macros_in_text, the pure-With stand-in for
a `cc -E` slice) refused a function-like macro invocation; it now
substitutes the invocation's arguments into the macro session's body for
that macro and expands the result, refusing a body that pastes or
stringifies, so a dispatch spelled through M*LIB's macros
(`M_STR1NG_SELECT2`, the hash selectors) reaches its association list.
With it, `<stdbool.h>`'s `true`/`false` lower as the literals they are,
not as D90 library constants (`SetDouble_in_str` returned `true`).
Three further facts the upstream test's selections needed. An
association typed by a typedef name whose TypeRef libclang does not
produce (M*LIB's `m_str1ng_t`) is resolved by scanning the translation
unit's typedef declarations once per session (ci_typedef_canonical_key).
An arm whose expression is spelled by a macro parameter, `type: (x),
default: (type) {0}`, is read from its parenthesized expression. Two
definitions of one function-like macro (`M_PRINTF_FORMAT_EXTEND()` is
defined empty in m-core.h and redefined in m-string.h) resolve to the
last one in both macro lookups, as the preprocessor does; the printf
format selections (`btree_get_str`, `SetDouble_out_str`) read their full
association lists. The goto-CFG assignment site keeps its inner bail
reason instead of the generic one. WITH_MIGRATE_TRACE_GENERIC=1 prints
each selection's expressions, segments, keys and the chosen arm.
… Phase 4 gate) `tests/test-mbptree.c` (eleven B+tree instantiations over int, double, string_t and testobj_t keys and values, multimaps and multisets) is migrated whole with m-core.h, m-string.h, m-bptree.h, tests/test-obj.h and tests/coverage.h beside it, in upstream's test configuration (`M_USE_STDIO=1`: tests/test-obj.h parses with fscanf outside any M_USE_STDIO guard; coverage.h keeps M_ASSERT without BUILD_COVERAGE), checked in under test/corpora/mlib/programs/test_mbptree, compiled by the release binary with the prelude off and run; its exit code is the verdict, as build/stc.w's lane does for STC's tests. Targets: mlib-migrate-tests, mlib-promote-tests, mlib-test-programs and the `-fresh` twin from the fresh migration (D112's migrator gate).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two layers, one battery.
C11
_Genericselects by the controlling expression's type. libclang's GenericSelectionExpr (kind 122) was grouped with the transparent wrappers and peeled to its last child, the default arm: M*LIB'sm_string_init_set(s, "text")called thestring_toverload with a C string, and the upstream B+tree test faulted at its first emplace. The selection follows C11 6.5.1.1 from the expression's preprocessed text (libclang names association types only as TypeRefs for typedef names): the controlling type after lvalue conversion, one spelling per integer synonym, typedef names resolved through the translation unit's typedef declarations, the first matching arm, elsedefault, else refused loudly. The text expander now substitutes function-like macro invocations (refusing#/##bodies) and the last definition of a redefined macro wins, as in the preprocessor.<stdbool.h>'strue/falselower as literals. Fixturegeneric_selection;WITH_MIGRATE_TRACE_GENERIC=1traces each selection.The mlib test lane (the Phase 4 gate). Upstream's
tests/test-mbptree.c(eleven B+tree instantiations; int, double, string_t, testobj_t keys and values; multimaps and multisets; I/O round trips) is migrated whole in upstream's test configuration (M_USE_STDIO=1), checked in undertest/corpora/mlib/programs/test_mbptree, compiled by the release binary with the prelude off and run; its exit code is the verdict, as STC's lane does. Targetsmlib-migrate-tests,mlib-promote-tests,mlib-test-programs(run bymlib-test, so:testhas it) andmlib-test-programs-fresh(incorpus-migrator-gate). The library corpus is untouched (D112): the test programs carry their ownUPSTREAMpin.Evidence: all thirteen upstream tests run to exit 0;
c-migrator-basic-testsgreen; the four lane targets green; gate and battery green on the top commit (posted below).Battery GREEN on 82d7b32 (334 s, seed-driven, this host).