Skip to content

Commit

Permalink
[Clang] Do not check for underscores in isAllowedInitiallyIDChar
Browse files Browse the repository at this point in the history
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.

Reviewed By: tahonermann, aaron.ballman

Differential Revision: https://reviews.llvm.org/D130750
  • Loading branch information
cor3ntin committed Jul 29, 2022
1 parent a7f55f0 commit ad16268
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Lex/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1483,13 +1483,13 @@ static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
}

static bool isAllowedInitiallyIDChar(uint32_t C, const LangOptions &LangOpts) {
assert(C > 0x7F && "isAllowedInitiallyIDChar called with an ASCII codepoint");
if (LangOpts.AsmPreprocessor) {
return false;
}
if (LangOpts.CPlusPlus || LangOpts.C2x) {
static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
// '_' doesn't have the XID_Start property but is allowed in C++.
return C == '_' || XIDStartChars.contains(C);
return XIDStartChars.contains(C);
}
if (!isAllowedIDChar(C, LangOpts))
return false;
Expand Down

0 comments on commit ad16268

Please sign in to comment.