mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
C++: Implement move constructor in terms of swap. I'm haven't found anything online on whether this is good or bad, and the only reason for not doing it might be performance.
This commit is contained in:
@@ -623,6 +623,14 @@
|
||||
| taint.cpp:483:18:483:19 | ref arg & ... | taint.cpp:483:19:483:19 | n [inner post update] | |
|
||||
| taint.cpp:483:19:483:19 | n | taint.cpp:483:18:483:19 | & ... | |
|
||||
| taint.cpp:483:28:483:34 | source1 | taint.cpp:483:11:483:15 | ref arg & ... | TAINT |
|
||||
| taint.cpp:491:14:491:14 | t | taint.cpp:491:14:491:14 | t | |
|
||||
| taint.cpp:491:14:491:14 | t | taint.cpp:491:14:491:14 | t | |
|
||||
| taint.cpp:491:14:491:14 | t | taint.cpp:491:52:491:52 | t | |
|
||||
| taint.cpp:491:14:491:14 | t | taint.cpp:491:52:491:52 | t | |
|
||||
| taint.cpp:501:3:501:7 | this | taint.cpp:501:25:501:28 | this | |
|
||||
| taint.cpp:501:17:501:20 | that | taint.cpp:501:17:501:20 | that | |
|
||||
| taint.cpp:501:17:501:20 | that | taint.cpp:501:30:501:33 | that | |
|
||||
| taint.cpp:501:30:501:33 | ref arg that | taint.cpp:501:17:501:20 | that | |
|
||||
| taint.cpp:502:3:502:7 | this | taint.cpp:502:30:502:44 | constructor init of field data [pre-this] | |
|
||||
| taint.cpp:502:22:502:25 | that | taint.cpp:502:35:502:38 | that | |
|
||||
| taint.cpp:502:40:502:43 | data | taint.cpp:502:30:502:44 | constructor init of field data | TAINT |
|
||||
@@ -698,3 +706,13 @@
|
||||
| taint.cpp:563:6:563:14 | ref arg call to move | taint.cpp:563:16:563:16 | x [inner post update] | |
|
||||
| taint.cpp:563:6:563:14 | ref arg call to move | taint.cpp:566:7:566:7 | x | |
|
||||
| taint.cpp:563:16:563:16 | x | taint.cpp:563:6:563:14 | call to move | |
|
||||
| taint.cpp:571:20:571:28 | move_from | taint.cpp:572:2:572:10 | move_from | |
|
||||
| taint.cpp:571:20:571:28 | move_from | taint.cpp:574:7:574:15 | move_from | |
|
||||
| taint.cpp:571:20:571:28 | move_from | taint.cpp:576:38:576:46 | move_from | |
|
||||
| taint.cpp:572:2:572:10 | move_from [post update] | taint.cpp:574:7:574:15 | move_from | |
|
||||
| taint.cpp:572:2:572:10 | move_from [post update] | taint.cpp:576:38:576:46 | move_from | |
|
||||
| taint.cpp:572:2:572:26 | ... = ... | taint.cpp:574:17:574:20 | data | |
|
||||
| taint.cpp:572:19:572:24 | call to source | taint.cpp:572:2:572:26 | ... = ... | |
|
||||
| taint.cpp:576:28:576:36 | ref arg call to move | taint.cpp:576:38:576:46 | move_from [inner post update] | |
|
||||
| taint.cpp:576:28:576:48 | call to Class | taint.cpp:578:7:578:13 | move_to | |
|
||||
| taint.cpp:576:38:576:46 | move_from | taint.cpp:576:28:576:36 | call to move | |
|
||||
|
||||
@@ -488,7 +488,7 @@ void test_getdelim(FILE* source1) {
|
||||
namespace std
|
||||
{
|
||||
template <class T>
|
||||
T &&move(T &t) noexcept; // simplified signature
|
||||
T &&move(T &t) noexcept { return static_cast<T&&>(t); } // simplified signature (and implementation)
|
||||
}
|
||||
|
||||
namespace IntWrapper
|
||||
@@ -498,7 +498,7 @@ namespace IntWrapper
|
||||
int data;
|
||||
|
||||
Class() = default;
|
||||
Class(Class&&) = default;
|
||||
Class(Class&& that) { swap(that); }
|
||||
Class(const Class &that) : data(that.data) {}
|
||||
|
||||
Class &operator=(const Class &that)
|
||||
@@ -565,3 +565,15 @@ void test_move_assignment_operator()
|
||||
sink(y.data); // tainted [FALSE NEGATIVE in IR]
|
||||
sink(x.data); // tainted
|
||||
}
|
||||
|
||||
void test_move_constructor()
|
||||
{
|
||||
IntWrapper::Class move_from;
|
||||
move_from.data = source();
|
||||
|
||||
sink(move_from.data); // tainted
|
||||
|
||||
IntWrapper::Class move_to(std::move(move_from));
|
||||
|
||||
sink(move_to.data); // tainted [FALSE NEGATIVE in IR]
|
||||
}
|
||||
|
||||
@@ -81,3 +81,6 @@
|
||||
| taint.cpp:565:9:565:12 | data | taint.cpp:556:20:556:20 | x |
|
||||
| taint.cpp:565:9:565:12 | data | taint.cpp:558:11:558:16 | call to source |
|
||||
| taint.cpp:566:9:566:12 | data | taint.cpp:558:11:558:16 | call to source |
|
||||
| taint.cpp:574:17:574:20 | data | taint.cpp:572:19:572:24 | call to source |
|
||||
| taint.cpp:578:15:578:18 | data | taint.cpp:571:20:571:28 | move_from |
|
||||
| taint.cpp:578:15:578:18 | data | taint.cpp:572:19:572:24 | call to source |
|
||||
|
||||
@@ -49,3 +49,5 @@
|
||||
| taint.cpp:551:10:551:13 | taint.cpp:544:24:544:25 | AST only |
|
||||
| taint.cpp:565:9:565:12 | taint.cpp:556:20:556:20 | AST only |
|
||||
| taint.cpp:565:9:565:12 | taint.cpp:558:11:558:16 | AST only |
|
||||
| taint.cpp:578:15:578:18 | taint.cpp:571:20:571:28 | AST only |
|
||||
| taint.cpp:578:15:578:18 | taint.cpp:572:19:572:24 | AST only |
|
||||
|
||||
@@ -44,3 +44,4 @@
|
||||
| taint.cpp:551:10:551:13 | data | taint.cpp:545:12:545:17 | call to source |
|
||||
| taint.cpp:560:9:560:12 | data | taint.cpp:558:11:558:16 | call to source |
|
||||
| taint.cpp:566:9:566:12 | data | taint.cpp:558:11:558:16 | call to source |
|
||||
| taint.cpp:574:17:574:20 | data | taint.cpp:572:19:572:24 | call to source |
|
||||
|
||||
Reference in New Issue
Block a user