This is an archive of the discontinued LLVM Phabricator instance.

[clang] modules: Fix callback argument thinko
ClosedPublic

Authored by urnathan on Oct 14 2022, 5:44 AM.

Details

Summary

VisbleModuleSet::setVisible takes a callback, to inform of modules
being made (transitively) visible. However, we were calling it as
'Vis(M)' from a recursive lambda, where 'M' is a capture of
setVisible's M, module parameter. Thus we can invoke the callback
multiple times, passing the same value to it each time.

Everywhere else in the lambda, we refer to V.M of the lambda's
Visiting parameter. We should be doing so for the callback. Thus
we'll pass the outermost module on the outermost recursive call, and
as we descend the imports, we'll pass each import to the callback.

AFAICT, there's no real use of the callback, which is probably why this has not been detected.

Diff Detail

Event Timeline

urnathan created this revision.Oct 14 2022, 5:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2022, 5:44 AM
urnathan requested review of this revision.Oct 14 2022, 5:44 AM
iains accepted this revision.Oct 17 2022, 12:25 AM

LGTM (the CI test fail seems spurious/unrelated, and does not repeat for me on macOS)

I guess there are not (m)any uses of the callback as you say - or the uses have not thrown up a failed test case.

This revision is now accepted and ready to land.Oct 17 2022, 12:25 AM
This revision was landed with ongoing or failed builds.Oct 17 2022, 9:31 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2022, 9:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript