[clang-tools-extra] [clang-tidy] Suggest materializing temporary ranges in readability-use-anyofallof (PR #185791)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Sat Apr 4 07:05:52 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);
----------------
5chmidti wrote:
Didn't try it, but `return false` would be: 'no note' for C++20, `return E->isPRValue()` would be 'note for temporaries'.
> I think we will need to suggest a note for these cases
-> unconditional note for temporaries, and instead have a pre-C++20 note and a post-C++20 note that suggests the ranges overloads?
https://github.com/llvm/llvm-project/pull/185791
More information about the cfe-commits
mailing list