This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix crash in Parser::ParseDirectDeclarator by adding check that token is not an annotation token
ClosedPublic

Authored by shafik on Aug 24 2023, 7:27 PM.

Details

Summary

In Parser::ParseDirectDeclarator(...) in some cases ill-formed code can cause an annotation token to end up where it was not expected. The fix is to add a !Tok.isAnnotation() guard before attempting to access identifier info.

This fixes:

https://github.com/llvm/llvm-project/issues/64836

Diff Detail

Event Timeline

shafik created this revision.Aug 24 2023, 7:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 7:27 PM
shafik requested review of this revision.Aug 24 2023, 7:27 PM
nridge accepted this revision.Sep 6 2023, 1:20 AM
nridge added a subscriber: rjmccall.

I'm not well versed in the parser code, but the fix clearly avoids the assertion in getIdentifierInfo(), and both @aaron.ballman and @rjmccall indicated in the issue discussion that this fix is appropriate, so I will take the liberty of approving this.

This revision is now accepted and ready to land.Sep 6 2023, 1:20 AM
shafik updated this revision to Diff 556590.Sep 12 2023, 10:11 AM
  • Add release note
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2023, 11:20 AM