Author: Corentin Jabot Date: 2022-07-29T17:46:38+02:00 New Revision: ad16268f135001bd21a805ae8acf8d8243793984
URL: https://github.com/llvm/llvm-project/commit/ad16268f135001bd21a805ae8acf8d8243793984 DIFF: https://github.com/llvm/llvm-project/commit/ad16268f135001bd21a805ae8acf8d8243793984.diff LOG: [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 Added: Modified: clang/lib/Lex/Lexer.cpp Removed: ################################################################################ diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index a4cff403e739c..6c1c55fc703fc 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits