The getSpelling() call otherwise ultimately runs into an assertion because getLength() is called on an annotation token.
Just ran into this when debugging using -dump-tokens.
Sorry I can't really find a better reviewer, the rest of that function seems to be pretty ancient.