This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Do not check for underscores in isAllowedInitiallyIDChar
ClosedPublic

Authored by cor3ntin on Jul 29 2022, 2:08 AM.

Details

Summary

isAllowedInitiallyIDChar is only used with non-ASCII codepoints,
which are handled by isAsciiIdentifierStart.
To make that clearer, remove the check for _ from
isAllowedInitiallyIDChar, and assert on ASCII - to ensure neither
_ or $ are passed to this function.

Diff Detail

Event Timeline

cor3ntin created this revision.Jul 29 2022, 2:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 2:08 AM
cor3ntin requested review of this revision.Jul 29 2022, 2:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 29 2022, 2:08 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

The change is fine by me, but you should put NFC in the patch title so it's more clear that this is simplifying code in a way that won't change behavior (and doesn't need tests).

clang/lib/Lex/Lexer.cpp
1486

nit: 80-col limit

Also, shouldn't this say it was called with an ASCII codepoint?

cor3ntin updated this revision to Diff 448581.EditedJul 29 2022, 4:33 AM

Fix assert message

cor3ntin added inline comments.Jul 29 2022, 4:35 AM
clang/lib/Lex/Lexer.cpp
1486

It should. I started with "isAllowedInitiallyIDChar should not be called with a non-ASCII codepoint") and... yeah, thanks for catching that!
It fits nicely in 80 cols too now :)

aaron.ballman accepted this revision.Jul 29 2022, 4:35 AM

LGTM assuming @tahonermann doesn't spot concerns.

This revision is now accepted and ready to land.Jul 29 2022, 4:35 AM
tahonermann accepted this revision.Jul 29 2022, 8:44 AM

LGTM, thanks Corentin.

Thank you both!