This is an archive of the discontinued LLVM Phabricator instance.

Parse: Don't crash on trailing whitespace before EOF
ClosedPublic

Authored by majnemer on Jul 23 2014, 12:48 PM.

Details

Summary

Parser::ParseDeclarationSpecifiers eagerly updates the source range of
the DeclSpec with the current token position. However, it might not
consume any more tokens.

Fix this by only setting the start of the range, not the end. This way
the SourceRange will be invalid if we don't consume any more tokens.

This fixes PR20413.

Diff Detail

Repository
rL LLVM

Event Timeline

majnemer updated this revision to Diff 11818.Jul 23 2014, 12:48 PM
majnemer retitled this revision from to Parse: Don't crash on trailing whitespace before EOF.
majnemer updated this object.
majnemer added a reviewer: rsmith.
majnemer added a subscriber: Unknown Object (MLST).
majnemer updated this revision to Diff 11819.Jul 23 2014, 1:15 PM
  • Forgot to add the test
rsmith accepted this revision.Jul 23 2014, 3:15 PM
rsmith edited edge metadata.
rsmith added inline comments.
lib/Parse/ParseDecl.cpp
2453 ↗(On Diff #11819)

Please add a comment explaining why we only set one of these.

This revision is now accepted and ready to land.Jul 23 2014, 3:15 PM
majnemer updated this revision to Diff 11824.Jul 23 2014, 3:27 PM
majnemer edited edge metadata.
  • Address Richard's review comments.
majnemer closed this revision.Jul 25 2014, 10:50 PM
majnemer updated this revision to Diff 11910.

Closed by commit rL214018 (authored by @majnemer).