This is an archive of the discontinued LLVM Phabricator instance.

[NFC][clang] Fix static analyzer concerns
ClosedPublic

Authored by Fznamznon on Jul 20 2023, 7:02 AM.

Details

Summary

HeaderIncludesCallback and HeaderIncludesJSONCallback classes may own
resources and free them in the destructor. However they don't have copy
user-written constructors/assignment operators, so an attempt to copy a
HeaderIncludesCallback object will use compiler-generated copy
constructor which will only do dummy copy and afterwards there will be
use-after-free issues.

Diff Detail

Event Timeline

Fznamznon created this revision.Jul 20 2023, 7:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 7:02 AM
Fznamznon requested review of this revision.Jul 20 2023, 7:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 7:02 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
This revision is now accepted and ready to land.Jul 20 2023, 11:34 AM
tahonermann accepted this revision.Jul 20 2023, 12:54 PM

This is a good change since the default copy constructor would do bad things when ownsOutputFile is true. The copy assignment operator is already implicitly deleted because of the presence of a data member of reference type, but I think it is helpful to explicitly delete both.

Fznamznon updated this revision to Diff 543420.Jul 24 2023, 1:56 AM

Rebase to maybe fix precommit

This revision was automatically updated to reflect the committed changes.