================
@@ -84,18 +84,33 @@ static bool isViableLoop(const CXXForRangeStmt &S,
ASTContext &Context) {
});
}
+static bool isIteratingOverTemporary(const Expr *Init) {
----------------
zeyi2 wrote:
TBH this is not a "perfect" fix for all cases.
There are additional cases where the range expression depends on a temporary
object through wrappers, but handling those would require a broader analysis of
the range expression and would expand the scope of this change. IMHO those are
better handled separately if we want to address them.
e.g.
```cpp
#include <utility>
#include <vector>
std::vector<int> g(int a, int b, int c) { return {a, b, c}; }
bool f(int a, int b, int c) {
for (int i : std::move(g(a, b, c))) {
if (i == 0)
return true;
}
return false;
}
```
https://github.com/llvm/llvm-project/pull/185791
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits