https://github.com/5chmidti commented:

The detected issues together with the fixes can currently produce code that 
can't compile. For example:

```diff
void f(std::string_view sv);
void g(std::string_view sv) {
-  const auto copy = sv = sv.substr(0, sv.length() - 3);                        
                                                                                
                                                                           
+  const auto copy = sv.remove_suffix(3);                                       
                                                                                
                                                                 
-  f(sv = sv.substr(0, sv.length() - 3));                                       
                                                                                
                                                                                
        
+  f(sv.remove_suffix(3));
}
```

I think the solution is to detect if the parent of the `CXXoperatorCallExpr` is 
an `ExprWithCleanup`: https://godbolt.org/z/d79MhEEea
Displaying a warning for these cases could still be done, just without the fix.

https://github.com/llvm/llvm-project/pull/120055
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to