Skip to content

Commit 952cc89

Browse files
committed
C++: Improve make_pair in stl.h (using remove_reference).
1 parent 7ecd229 commit 952cc89

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,31 +1981,31 @@
19811981
| standalone_iterators.cpp:51:37:51:43 | source1 | standalone_iterators.cpp:53:12:53:18 | source1 | |
19821982
| standalone_iterators.cpp:51:37:51:43 | source1 | standalone_iterators.cpp:54:14:54:20 | source1 | |
19831983
| standalone_iterators.cpp:53:12:53:18 | ref arg source1 | standalone_iterators.cpp:54:14:54:20 | source1 | |
1984-
| stl.h:222:30:222:40 | call to allocator | stl.h:222:21:222:41 | noexcept(...) | TAINT |
1985-
| stl.h:222:30:222:40 | call to allocator | stl.h:222:21:222:41 | noexcept(...) | TAINT |
1986-
| stl.h:222:30:222:40 | call to allocator | stl.h:222:21:222:41 | noexcept(...) | TAINT |
1987-
| stl.h:222:30:222:40 | call to allocator | stl.h:222:21:222:41 | noexcept(...) | TAINT |
1988-
| stl.h:222:30:222:40 | call to allocator | stl.h:222:21:222:41 | noexcept(...) | TAINT |
1989-
| stl.h:222:53:222:63 | 0 | stl.h:222:46:222:64 | (no string representation) | TAINT |
1990-
| stl.h:315:9:315:9 | Unknown literal | stl.h:315:9:315:9 | constructor init of field first | TAINT |
1991-
| stl.h:315:9:315:9 | Unknown literal | stl.h:315:9:315:9 | constructor init of field second | TAINT |
1992-
| stl.h:315:9:315:9 | constructor init of field first [post-this] | stl.h:315:9:315:9 | constructor init of field second [pre-this] | |
1993-
| stl.h:315:9:315:9 | constructor init of field first [pre-this] | stl.h:315:9:315:9 | constructor init of field second [pre-this] | |
1994-
| stl.h:315:9:315:9 | this | stl.h:315:9:315:9 | constructor init of field first [pre-this] | |
1995-
| stl.h:322:3:322:3 | this | stl.h:322:36:322:43 | constructor init of field first [pre-this] | |
1996-
| stl.h:322:3:322:6 | this | stl.h:322:36:322:43 | constructor init of field first [pre-this] | |
1997-
| stl.h:322:18:322:18 | x | stl.h:322:42:322:42 | x | |
1998-
| stl.h:322:18:322:18 | x | stl.h:322:42:322:42 | x | |
1999-
| stl.h:322:31:322:31 | y | stl.h:322:53:322:53 | y | |
2000-
| stl.h:322:31:322:31 | y | stl.h:322:53:322:53 | y | |
2001-
| stl.h:322:36:322:43 | call to unknown function | stl.h:322:36:322:43 | constructor init of field first | TAINT |
2002-
| stl.h:322:36:322:43 | constructor init of field first [post-this] | stl.h:322:46:322:54 | constructor init of field second [pre-this] | |
2003-
| stl.h:322:36:322:43 | constructor init of field first [post-this] | stl.h:322:46:322:54 | constructor init of field second [pre-this] | |
2004-
| stl.h:322:36:322:43 | constructor init of field first [pre-this] | stl.h:322:46:322:54 | constructor init of field second [pre-this] | |
2005-
| stl.h:322:36:322:43 | constructor init of field first [pre-this] | stl.h:322:46:322:54 | constructor init of field second [pre-this] | |
2006-
| stl.h:322:42:322:42 | x | stl.h:322:36:322:43 | constructor init of field first | TAINT |
2007-
| stl.h:322:46:322:54 | call to unknown function | stl.h:322:46:322:54 | constructor init of field second | TAINT |
2008-
| stl.h:322:53:322:53 | y | stl.h:322:46:322:54 | constructor init of field second | TAINT |
1984+
| stl.h:235:30:235:40 | call to allocator | stl.h:235:21:235:41 | noexcept(...) | TAINT |
1985+
| stl.h:235:30:235:40 | call to allocator | stl.h:235:21:235:41 | noexcept(...) | TAINT |
1986+
| stl.h:235:30:235:40 | call to allocator | stl.h:235:21:235:41 | noexcept(...) | TAINT |
1987+
| stl.h:235:30:235:40 | call to allocator | stl.h:235:21:235:41 | noexcept(...) | TAINT |
1988+
| stl.h:235:30:235:40 | call to allocator | stl.h:235:21:235:41 | noexcept(...) | TAINT |
1989+
| stl.h:235:53:235:63 | 0 | stl.h:235:46:235:64 | (no string representation) | TAINT |
1990+
| stl.h:328:9:328:9 | Unknown literal | stl.h:328:9:328:9 | constructor init of field first | TAINT |
1991+
| stl.h:328:9:328:9 | Unknown literal | stl.h:328:9:328:9 | constructor init of field second | TAINT |
1992+
| stl.h:328:9:328:9 | constructor init of field first [post-this] | stl.h:328:9:328:9 | constructor init of field second [pre-this] | |
1993+
| stl.h:328:9:328:9 | constructor init of field first [pre-this] | stl.h:328:9:328:9 | constructor init of field second [pre-this] | |
1994+
| stl.h:328:9:328:9 | this | stl.h:328:9:328:9 | constructor init of field first [pre-this] | |
1995+
| stl.h:335:3:335:3 | this | stl.h:335:36:335:43 | constructor init of field first [pre-this] | |
1996+
| stl.h:335:3:335:6 | this | stl.h:335:36:335:43 | constructor init of field first [pre-this] | |
1997+
| stl.h:335:18:335:18 | x | stl.h:335:42:335:42 | x | |
1998+
| stl.h:335:18:335:18 | x | stl.h:335:42:335:42 | x | |
1999+
| stl.h:335:31:335:31 | y | stl.h:335:53:335:53 | y | |
2000+
| stl.h:335:31:335:31 | y | stl.h:335:53:335:53 | y | |
2001+
| stl.h:335:36:335:43 | call to unknown function | stl.h:335:36:335:43 | constructor init of field first | TAINT |
2002+
| stl.h:335:36:335:43 | constructor init of field first [post-this] | stl.h:335:46:335:54 | constructor init of field second [pre-this] | |
2003+
| stl.h:335:36:335:43 | constructor init of field first [post-this] | stl.h:335:46:335:54 | constructor init of field second [pre-this] | |
2004+
| stl.h:335:36:335:43 | constructor init of field first [pre-this] | stl.h:335:46:335:54 | constructor init of field second [pre-this] | |
2005+
| stl.h:335:36:335:43 | constructor init of field first [pre-this] | stl.h:335:46:335:54 | constructor init of field second [pre-this] | |
2006+
| stl.h:335:42:335:42 | x | stl.h:335:36:335:43 | constructor init of field first | TAINT |
2007+
| stl.h:335:46:335:54 | call to unknown function | stl.h:335:46:335:54 | constructor init of field second | TAINT |
2008+
| stl.h:335:53:335:53 | y | stl.h:335:46:335:54 | constructor init of field second | TAINT |
20092009
| string.cpp:24:12:24:17 | call to source | string.cpp:28:7:28:7 | a | |
20102010
| string.cpp:25:16:25:20 | 123 | string.cpp:25:16:25:21 | call to basic_string | TAINT |
20112011
| string.cpp:25:16:25:21 | call to basic_string | string.cpp:29:7:29:7 | b | |

cpp/ql/test/library-tests/dataflow/taint-tests/stl.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ struct remove_const<const T> { typedef T type; };
1111
template<class T>
1212
using remove_const_t = typename remove_const<T>::type;
1313

14+
template<class T>
15+
struct remove_reference { typedef T type; };
16+
17+
template<class T>
18+
struct remove_reference<T &> { typedef T type; };
19+
20+
template<class T>
21+
struct remove_reference<T &&> { typedef T type; };
22+
23+
// `remove_reference_t<T>` removes any `&` from `T`
24+
template<class T>
25+
using remove_reference_t = typename remove_reference<T>::type;
26+
1427
// --- iterator ---
1528

1629
namespace std {
@@ -324,7 +337,8 @@ namespace std {
324337

325338
void swap(pair& p) /*noexcept(...)*/;
326339
};
327-
template< class T1, class T2 > std::pair<T1,T2> make_pair(const T1& t, const T2& u );
340+
341+
template<class T1, class T2> constexpr pair<remove_reference_t<T1>, remove_reference_t<T2>> make_pair(T1&& x, T2&& y);
328342
}
329343

330344
// --- map ---

0 commit comments

Comments
 (0)