[clang] clang: Relax LangOpts checks when lexing quoted numbers during preprocessing (PR #95798)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 21 16:33:24 PDT 2024


================
@@ -2068,7 +2068,8 @@ bool Lexer::LexNumericConstant(Token &Result, const char *CurPtr) {
   }
 
   // If we have a digit separator, continue.
-  if (C == '\'' && (LangOpts.CPlusPlus14 || LangOpts.C23)) {
+  if (C == '\'' &&
+      (LangOpts.CPlusPlus14 || LangOpts.C23 || ParsingPreprocessorDirective)) {
----------------
jansvoboda11 wrote:

Why is `ParsingPreprocessorDirective` used here?

I think I would prefer introducing new `LangOptions::AllowLiteralDigitSeparator` member that would be set to true whenever `CPlusPlus14 || C23` evaluates to `true` and that could be set to `true` explicitly from the scanner. WDYT?

https://github.com/llvm/llvm-project/pull/95798


More information about the cfe-commits mailing list