This is an archive of the discontinued LLVM Phabricator instance.

[-Wunsafe-buffer-usage] Check source location validity before using `TypeLoc`s
ClosedPublic

Authored by ziqingluo-90 on Jul 18 2023, 6:42 PM.

Details

Summary

The safe-buffer analysis analyzes TypeLocs of types of variable declarations in order to get source locations of them.

However, in some cases, the source locations of a TypeLoc are not valid. Using invalid source locations results in assertion violation or incorrect analysis or fix-its.

It is still not clear to me in what circumstances a TypeLoc does not have valid source locations (it looks like a bug in Clang to me, but it is not our responsibility to fix it). So we will conservatively give up the analysis when required source locations are not valid.

Diff Detail

Event Timeline

ziqingluo-90 created this revision.Jul 18 2023, 6:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 6:42 PM
ziqingluo-90 requested review of this revision.Jul 18 2023, 6:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 6:42 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
NoQ accepted this revision.Jul 19 2023, 1:32 PM

LGTM!

This revision is now accepted and ready to land.Jul 19 2023, 1:32 PM