[PATCH] D158372: [Clang] Treat invalid UDL as two tokens
Corentin Jabot via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 21 00:43:57 PDT 2023
cor3ntin added inline comments.
================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9322
def warn_user_literal_reserved : Warning<
- "user-defined literal suffixes %select{<ERROR>|not starting with '_'|containing '__'}0 are reserved"
- "%select{; no literal will invoke this operator|}1">,
+ "user-defined literal suffixes %select{<ERROR>|not starting with '_'|containing '__'}0 are reserved">,
InGroup<UserDefinedLiterals>;
----------------
Can you remove `<Error>` and adapt the calling code to adjust the index?
================
Comment at: clang/lib/Lex/Lexer.cpp:1994-2009
if (!isAsciiIdentifierStart(C)) {
if (C == '\\' && tryConsumeIdentifierUCN(CurPtr, Size, Result))
Consumed = true;
else if (!isASCII(C) && tryConsumeIdentifierUTF8Char(CurPtr))
Consumed = true;
else
return CurPtr;
----------------
I missed that in the previous review, is the FIX-IT here still relevant?
================
Comment at: clang/lib/Lex/Lexer.cpp:2024
+ // the 'operator""if' defining a numeric literal operator).
+ const unsigned MaxStandardSuffixLength = 3;
+ char Buffer[MaxStandardSuffixLength] = {C};
----------------
This sounds brittle. I think we are better off looking ahead to the next non-identifier character rather than assuming a size here
================
Comment at: clang/lib/Lex/Lexer.cpp:2031
+ char Next = getCharAndSizeNoWarn(CurPtr + Consumed, NextSize, LangOpts);
+ if (!isAsciiIdentifierContinue(Next)) {
+ // End of suffix. Check whether this is on the allowed list.
----------------
This is also sort of brittle, it assumes standard UDL don't have unicode... but that sounds more reasonable today.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158372/new/
https://reviews.llvm.org/D158372
More information about the cfe-commits
mailing list