================
@@ -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)) {
----------------
Sirraide wrote:

> Sure, but we don't have to expose that language extension to users, it can 
> remain internal to the compiler.

Yeah, that’s fine. What I meant was if we were to just use 
`ParsingPreprocessorDirective`, we would be exposing it to users, so that’s 
probably not the way to go imo.

> The scanner works in two steps:
> 
> 1. The virtual file system "minimizes" source files into sequence of tokens 
> that are relevant for dependency discovery. Your code fragment would be 
> transformed into something like `[if, ident, gte, ident, then, include, 
> string, else, include, string, endif]`.
> 2. The scanner instance takes those tokens and the TU `LanguageOptions` and 
> runs full preprocessor on those tokens. This means that the condition should 
> evaluate correctly.

I see; in that case being more permissive in what we accept during step 1 makes 
perfect sense imo. I don’t think there are *that* many language features that 
affect this step either since that’s basically just preprocessor directives 
from what I gather, so adding language options for whatever features we need to 
enable for this seems reasonable.

https://github.com/llvm/llvm-project/pull/95798
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to