This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Make sure ScanInstance outlives collector
ClosedPublic

Authored by jansvoboda11 on Sep 15 2022, 4:24 PM.

Details

Summary

The ScanInstance is a local variable in DependencyScanningAction::runInvocation() that is referenced by ModuleDepCollector. Since D132405, ModuleDepCollector can escape the function and can outlive its ScanInstance. This patch fixes that.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Sep 15 2022, 4:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2022, 4:24 PM
jansvoboda11 requested review of this revision.Sep 15 2022, 4:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2022, 4:24 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Another option would be to store ScanInstance as member of DependencyScanningAction.

Replace std::shared_ptr by Optional stored on DependencyScanningAction.

jansvoboda11 edited the summary of this revision. (Show Details)Sep 15 2022, 4:46 PM
benlangmuir accepted this revision.Sep 16 2022, 7:52 AM

Good catch, thanks!

This revision is now accepted and ready to land.Sep 16 2022, 7:52 AM