[clang-tools-extra] [clang-tidy] Avoid readability-use-anyofallof diagnostics on temporary ranges before C++20 (PR #185791)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 11:14:03 PDT 2026
================
@@ -35,6 +35,13 @@ AST_MATCHER_P(Stmt, nextStmt, ast_matchers::internal::Matcher<Stmt>,
return InnerMatcher.matches(**I, Finder, Builder);
}
+
+AST_MATCHER(Expr, isUnsupportedRangeInit) {
+ const Expr *E = Node.IgnoreParenImpCasts();
+ if (Finder->getASTContext().getLangOpts().CPlusPlus20)
+ return isa<CXXStdInitializerListExpr>(E);
----------------
localspook wrote:
In my understanding, and correct me if I'm wrong: we don't want the check to warn on a for-range loop over a raw initializer list in *any* language mode. It's what the current tests assert. But here the exclusion is limited to C++20 and up, as if we *did* want the check to warn in pre-C++20. So is this condition doing anything? :thinking:
https://github.com/llvm/llvm-project/pull/185791
More information about the cfe-commits
mailing list