https://github.com/usx95 commented:

```cpp
void for_loop_use_before_loop_body(MyObj safe) {
  MyObj* p = &safe;
  for (int i = 0; i < 1; ++i) {
    (void)*p;
    MyObj s;
    p = &s;
  }
  (void)*p;
}
```
> So I no longer use StartPoint as the initial search starting point; it is 
> only used to locate the corresponding block.

This seems inaccurate. This would not work when the we do not have the target 
loan in the origin at the end of block.

```cpp
void test() {
  int *p, *q, *r;
  {
    int a;
    p = &a;  // First assignment
    q = p;
    r = q;
  }
  (void)*r; // Use 1  

  int b; 
  r = &b;  // Overwrite the previous loan  
  (void)*r; // Use 2 - this is new StartPoint
}
```
Can you try to see if this works (highlight `p,q,r`)?

---

Some interesting test case which you should add:

```cpp
void cycle_4(bool condition) {
  int v1, v2, v3;
  int *p1, *p2, *p3, *p4;
  {
    int v4;

    p1 = &v1;
    p2 = &v2;
    p3 = &v3;
    p4 = &v4;

    while (condition) {
      int *temp = p1;
      p1 = p2;
      p2 = p3;
      p3 = p4;
      p4 = temp;
    }
  }
  (void)p1;
}
```
I think this will make the loop body visited multiple times with different 
origins. 

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

Reply via email to