This is an archive of the discontinued LLVM Phabricator instance.

[NFC][clang] Fix static analyzer concerns
AbandonedPublic

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

Details

Summary

Preprocessor class can own and free resources in its destructor, but
doesn't have user-written copy constructor or assignment operator, hence
any copy attempt will use compiler-generated copy constructor and may
cause use-after-free problems.

Diff Detail

Event Timeline

Fznamznon created this revision.Jul 20 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 7:48 AM
Fznamznon requested review of this revision.Jul 20 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2023, 7:48 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I'm not opposed, but the copy ctor and copy assignment operators are already deleted by default in this case (e.g., the class has data members with deleted copy constructors). So I agree this is an NFC change, but there's no bug being fixed which makes me think this should go back to the static analysis vendor to report this as a false positive.

there's no bug being fixed which makes me think this should go back to the static analysis vendor to report this as a false positive.

I agree. I'll try to isolate a reproducible test case and report it to the vendor.

I agree. I'll try to isolate a reproducible test case and report it to the vendor.

Done.

I'm ambivalent with regard to keeping or discarding the proposed change, but the static analysis issue should be triaged as a false positive.

Fznamznon abandoned this revision.Jul 24 2023, 1:37 AM

Oh shoot, I trusted the tool too much to not double check that the copy ctor is already deleted. Thank you for the catch and for the bug report.
I'll abandon this change then.