[clang] clang: Relax LangOpts checks when lexing quoted numbers during preprocessing (PR #95798)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 3 10:25:44 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)) {
----------------
AaronBallman wrote:
>> I'm still wondering about the question I asked here: https://github.com/llvm/llvm-project/pull/93753#issuecomment-2173666602
> Are there any comments that weren't addressed by https://github.com/llvm/llvm-project/pull/93753#issuecomment-2204578263?
Oh, thank you for pointing that out, somehow I missed that you commented (sorry)! I'll keep the discussion over there.
> This doesn't need to scale. We'd only do this for options that control lexing. FWIW, code that says "literal digit separators are enabled in C++14+, C23+, or when explicitly allowed" seems more logical to me than checking ParsingPreprocessorDirective, which doesn't really explain why we're suddenly allowing digit separators.
Yeah, this was the bit I think I was missing from the earlier discussion. Making sure I understand correctly, it's not *all* tokens we need to care about, it's only ones that matter for scanning of dependencies, which basically means punctuators, preprocessor directive keywords, and literals? Or do you mean "control lexing" in terms of what is or isn't a keyword (e.g., `_Atomic` is a keyword in C and C++ except when OpenCL is enabled)?
https://github.com/llvm/llvm-project/pull/95798
More information about the cfe-commits
mailing list