This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix unconditional access to Attr pointer when checking if _Nullable is applicable to a type
ClosedPublic

Authored by shafik on Jan 27 2023, 10:47 PM.

Details

Summary

In TransformAttributedType(...) when checking if _Nullable can be applied to a type it dereferences TL.getAttr() unconditionally which we can see from the code earlier in the function is not correct since it is expected to be nullptr in some cases.

It looks like the correct course of action is to use TL.getModifiedLoc() over TL.getAttr()->getLocation() in the case that TL.getAttr() returns a nullptr.

Fixes: https://github.com/llvm/llvm-project/issues/60344

Diff Detail

Event Timeline

shafik created this revision.Jan 27 2023, 10:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2023, 10:47 PM
shafik requested review of this revision.Jan 27 2023, 10:47 PM
gribozavr2 accepted this revision.Jan 30 2023, 6:08 AM
gribozavr2 added a subscriber: gribozavr2.

Thank you for the fix!

This revision is now accepted and ready to land.Jan 30 2023, 6:08 AM
erichkeane accepted this revision.Jan 30 2023, 6:09 AM

Needs a release note, otherwise LGTM.

shafik updated this revision to Diff 493351.Jan 30 2023, 10:20 AM
  • Add release note
gribozavr2 accepted this revision.Jan 30 2023, 11:05 AM
gribozavr2 added inline comments.
clang/docs/ReleaseNotes.rst
60
shafik updated this revision to Diff 493389.Jan 30 2023, 1:06 PM
shafik marked an inline comment as done.
  • Fix up release notes

The build failures look unrelated to this change.

This revision was landed with ongoing or failed builds.Jan 30 2023, 1:28 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2023, 1:28 PM