https://github.com/zeyi2 requested changes to this pull request.

Sorry that I didn't have the condition to compile the code locally, so you may 
need to verify this on your side.

---

I think removing the `hasInitStorage()` check will cause the existing Fix-it 
logic to generate broken code. IMO the current implementation deletes the 
initialization statement:

```cpp
if (int x = val; true) {
    return x;
}
```
With this patch, Clang-Tidy will suggest replacing it with:

```cpp
{
    return x; // invalid code gen
}
```

So I think updating the replacement logic is necessary. (e.g. in 
`replaceWithThen/ElseStatement`, check `getInit()` then extract its source text)

Also, it may be reasonable to wrap the replacement in a new scope to preserve 
variable lifetimes.

https://github.com/llvm/llvm-project/pull/172220
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to