[clang] clang: Relax LangOpts checks when lexing quoted numbers during preprocessing (PR #95798)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 15 14:24:37 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:
We've been trying to avoid specializing Clang itself for dependency scanning. Instead, we have introduced generic feature flags that the scanner uses to tweak the compiler behavior. I think this is better for layering and also forces us to name those features, making the code self-documenting. People working on Clang don't have to wonder what's dependency scanning and why it needs to lex numeric literals differently; they just see there's a feature flag named `AllowLiteralDigitSeparator` that just makes sense in that context. You can still dive deeper and find that it's the scanner that enables that feature of course.
So I'm not a fan of introducing `LanguageOpts::ScanningDependencies`.
https://github.com/llvm/llvm-project/pull/95798
More information about the cfe-commits
mailing list