Diagnose dangling pointers that come from std::stack::top() and std::optional::value().
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
LG! But let's wait for Dmitri :)
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp | ||
---|---|---|
172 ↗ | (On Diff #214912) | I actually was a bit lazy when I added these tests. Both value and operator* is overloaded on &&. But if you do not feel like adjusting the tests this is fine, I can do it myself later :) |
clang/lib/Sema/SemaInit.cpp | ||
---|---|---|
6583 ↗ | (On Diff #214912) | Oh, this one needs to be updated, as value returns a reference not a pointer. |
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp | ||
---|---|---|
172 ↗ | (On Diff #214912) | I'll change it to use the & variant in the test - the && cannot dangle as far as I understand. |
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp | ||
---|---|---|
172 ↗ | (On Diff #214912) | It can! Consider the following code: int &&r = *std::optional(5); // r dangles here. |