Skip to content

Commit ad16268

Browse files
committed
[Clang] Do not check for underscores in isAllowedInitiallyIDChar
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
1 parent a7f55f0 commit ad16268

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Lex/Lexer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,13 +1483,13 @@ static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
14831483
}
14841484

14851485
static bool isAllowedInitiallyIDChar(uint32_t C, const LangOptions &LangOpts) {
1486+
assert(C > 0x7F && "isAllowedInitiallyIDChar called with an ASCII codepoint");
14861487
if (LangOpts.AsmPreprocessor) {
14871488
return false;
14881489
}
14891490
if (LangOpts.CPlusPlus || LangOpts.C2x) {
14901491
static const llvm::sys::UnicodeCharSet XIDStartChars(XIDStartRanges);
1491-
// '_' doesn't have the XID_Start property but is allowed in C++.
1492-
return C == '_' || XIDStartChars.contains(C);
1492+
return XIDStartChars.contains(C);
14931493
}
14941494
if (!isAllowedIDChar(C, LangOpts))
14951495
return false;

0 commit comments

Comments
 (0)