Issue 177986
Summary [LifetimeSafety][Diagnostics] Make it clearer how a loan ended up being used after it is destroyed
Labels clang:temporal-safety
Assignees
Reporter usx95
    The idea for improvement is to highlight all the expressions/statements responsible for loan propagation of the expired loan to an origin which is used after the loan expires.
```cpp
#include <iostream>
#include <string>
#include <string_view>

void foo() {
    std::string_view f;
 {
        std::string str = "small scoped string";
 std::string_view a, b, c, d, e;
        a = str;  // Ok. error: object whose reference is captured does not live long enough.
                  // TODO: add note: 'a' aliases 'str'
        b = a;
        c = a;  // TODO: add note: 'c' aliases 'a'
        d = c;  // TODO: add note: 'd' aliases 'c'
 e = d;
        f = d;  // TODO: add note: 'f' aliases 'd'
    }
 std::cout << f;
}
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to