Merge pull request #16440 from MathiasVP/fix-iterator-to-expired-container-fp-2

C++: Fix location of SSA def for local variable addresses
This commit is contained in:
Mathias Vorreiter Pedersen
2024-05-07 14:39:13 +01:00
committed by GitHub
3 changed files with 23 additions and 6 deletions

View File

@@ -1,7 +1,5 @@
| test.cpp:680:30:680:30 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:683:31:683:32 | call to at | This object is destroyed at the end of the full-expression. |
| test.cpp:689:46:689:58 | pointer to ~vector output argument | This object is destroyed at the end of the full-expression. |
| test.cpp:702:27:702:27 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:727:23:727:23 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:735:23:735:23 | call to operator[] | This object is destroyed at the end of the full-expression. |
| test.cpp:803:3:803:3 | pointer to ~vector output argument | This object is destroyed at the end of the full-expression. |

View File

@@ -686,7 +686,7 @@ void test() {
for (auto x : returnRef()[0]) {} // GOOD
for (auto x : returnRef().at(0)) {} // GOOD
for(auto it = returnValue().begin(); it != returnValue().end(); ++it) {} // BAD
for(auto it = returnValue().begin(); it != returnValue().end(); ++it) {} // BAD [NOT DETECTED]
{
auto v = returnValue();
@@ -800,5 +800,5 @@ void test5(int i)
const auto& vvs = returnValue();
for(const auto& vs : vvs) { }
++i;
} // GOOD [FALSE POSITIVE]
} // GOOD
}