[clang] clang: Relax LangOpts checks when lexing quoted numbers during preprocessing (PR #95798)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 05:53:48 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)) {
----------------
cor3ntin wrote:
> We've been trying to avoid specializing Clang itself for dependency scanning
Except the only reason for these flags to exists is because of dependency scanning.
The sad reality is that there are preprocessor divergence across language modes and the only way we can avoid that is by creating a dialect.
I do agree with you that we should 1/ Try to minimize such divergences and 2/ Document the preprocessor as understood by the dependency scanner.
As this PR shows, Clang cannot ignore the existence of this dialect, and I think being coy about it isn't in fact making maintenance either: ultimately, there is a tension between C and C++ preprocessor evolving and sometimes diverging, and tooling needing to pretend the preprocessor is not affected by language mode.
Clang needs to deal with that and I don't think it's wide to bury that in the driver or to add lots of very targeted flags that will only ever make sense in context of dependency scanning.
https://github.com/llvm/llvm-project/pull/95798
More information about the cfe-commits
mailing list