================
@@ -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);
----------------
zeyi2 wrote:
> we don't want the check to warn on a for-range loop over a raw initializer
> list in _any_ language mode
Yes! To clarify (and make review easier), my original intention is:
- suppress diagnostics for all prvalue range initializers in pre-C++20 mode
(rewriting them might not be safe).
- In c++20-or-later, I want to allow diagnostics again for *ordinary* range
expressions (`any_of` and `all_of` can consume the range directly).
The special case for `CXXStdInitializerListExpr` (`{a, b, c}`), we still should
not diagnose in any language mode, since they cannot be directly reused in the
replacement.
> But here the exclusion is limited to C++20 and up, as if we did want the
> check to warn in pre-C++20.
No, `return E->isPRValue();` already filters that for cases below C++ 20.
> So is this condition doing anything? 🤔
Yes! It re-enable diagnostics for ordinary temporary range expressions in
C++20, while still keeping raw braced-init-lists excluded.
https://github.com/llvm/llvm-project/pull/185791
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits