Repository navigation
Evaluate rule arguments with side effects even when the rule ignores them - #693
Merged
nunoplopes merged 2 commits intoDec 2, 2026
Merged
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
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.
Mapped calls can silently skip side effects when a rule ignores an operand, in both refcount and unsafe output. For example,
pick(a, &calls).size()must callpickeven though the array-size rule expands to a constant. With a one-element array andcalls = 0, the size is correctly translated as 1, butcallsstays 0 instead of becoming 1.Omitted side-effectful operands are bound before expanding the rule body, using the existing temporary-binding machinery. Preceding operand values are captured before those effects can change what they read. Global initializers get an expansion-local binding context when an omitted operand is bound, while retaining the existing init-fragment path.
Operands that Clang itself drops stay dropped: compile-time constants such as the
0ino < 0, and operands of builtins Clang folds, such as__builtin_expect(1, ++n).The new
tests/unit/mapped_unused_args.cppcovers global initialization, array and temporary receivers, evaluation order and preceding-value snapshots, a pointer operand passed tonanf, and pure/folded controls. Generated output is unchanged for every existing test; the new test passes in both refcount and unsafe output.Converter run time on
tests/unit/operator_three_way.cpp, which runs the changed code but not the fixed case, did not change measurably over 48 paired runs: the difference (base minus change; positive is faster) was −5.0 to +8.8 ms in refcount output and −3.6 to +7.0 ms in unsafe output.cc @nunoplopes
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.