[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 04:34:25 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:
There's not a one-to-one mapping of `LangOptions` to frontend of driver options, yes. But I think it's a stretch to argue that the standard mode tracked by `LangOptions` is not exposed via flags.
I don't think per-feature `LangOptions` is viable. There's digit separators, hex float support, binary literal support, different literal suffixes, various keywords, etc and that doesn't seem likely to scale well. Also, it makes it seem like we support a la carte language features when we don't -- we intentionally don't want to let users disable standard features (in general; exceptions exist) and so that approach gives the impression contributors need to check both language mode and feature availability which is a maintenance concern.
I'm still wondering about the question I asked here: https://github.com/llvm/llvm-project/pull/93753#issuecomment-2173666602
https://github.com/llvm/llvm-project/pull/95798
More information about the cfe-commits
mailing list