Skip to content

Commit d6bf61a

Browse files
committed
C++: Big cleanup of declarations in the taint-tests to get rid of duplicated std::string declarations in 'azure.cpp' and 'bslx.cpp'.
1 parent 7abf69d commit d6bf61a

13 files changed

Lines changed: 1604 additions & 1657 deletions

File tree

‎cpp/ql/test/include/type_traits.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#if !defined(CODEQL_TYPE_TRAITS_H)
22
#define CODEQL_TYPE_TRAITS_H
33

4-
typedef unsigned long size_t;
4+
using size_t = decltype(sizeof(0));
55

66
namespace std {
7+
using size_t = decltype(sizeof(0));
78
template<class T>
89
struct remove_const { typedef T type; };
910

‎cpp/ql/test/library-tests/dataflow/external-models/asio_streams.cpp‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11

22
// --- stub library headers ---
33

4-
#include "std_string.h"
4+
#include "../taint-tests/stl.h"
55

66
#define SIZE_MAX 0xFFFFFFFF
77

8-
namespace std {
9-
class string_view {
10-
public:
11-
string_view(const char* s);
12-
};
13-
};
14-
158
namespace boost {
169
namespace system {
1710
class error_code {

‎cpp/ql/test/library-tests/dataflow/external-models/azure.cpp‎

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,11 @@
1+
#include "../taint-tests/stl.h"
12
using uint16_t = unsigned short;
23
using int64_t = long long;
34
using size_t = unsigned long;
45
using uint8_t = unsigned char;
56
using int32_t = int;
67
using uint32_t = unsigned int;
78

8-
namespace std
9-
{
10-
template <class T1, class T2>
11-
struct pair {
12-
typedef T1 first_type;
13-
typedef T2 second_type;
14-
15-
T1 first;
16-
T2 second;
17-
pair();
18-
pair(const T1& x, const T2& y);
19-
template<class U, class V> pair(const pair<U, V> &p);
20-
21-
void swap(pair& p) /*noexcept(...)*/;
22-
};
23-
24-
template<class charT> struct char_traits;
25-
26-
typedef size_t streamsize;
27-
28-
template <class T> class allocator {
29-
public:
30-
allocator() throw();
31-
typedef size_t size_type;
32-
};
33-
34-
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
35-
class basic_string {
36-
public:
37-
using value_type = charT;
38-
using reference = value_type&;
39-
using const_reference = const value_type&;
40-
typedef typename Allocator::size_type size_type;
41-
42-
basic_string(const charT* s, const Allocator& a = Allocator());
43-
};
44-
45-
typedef basic_string<char> string;
46-
47-
template <typename K, typename V>
48-
class map
49-
{
50-
public:
51-
using key_type = K;
52-
using value_type = pair<const K, V>;
53-
map();
54-
~map();
55-
56-
V& operator[](const key_type& key);
57-
};
58-
59-
template <typename T>
60-
class vector
61-
{
62-
public:
63-
vector();
64-
~vector();
65-
66-
T& operator[](size_t);
67-
};
68-
69-
template<typename T>
70-
class unique_ptr {
71-
public:
72-
unique_ptr();
73-
~unique_ptr();
74-
75-
T* get();
76-
};
77-
}
78-
799
namespace Azure
8010
{
8111
template <typename T>

‎cpp/ql/test/library-tests/dataflow/external-models/bslx.cpp‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
1-
2-
// --- stub library headers ---
3-
4-
namespace std {
5-
typedef unsigned long size_t;
6-
template <class T> class allocator {};
7-
template<class charT> struct char_traits {};
8-
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
9-
class basic_string {
10-
public:
11-
basic_string();
12-
basic_string(const charT* s, const Allocator& a = Allocator());
13-
const charT* data() const;
14-
size_t size() const;
15-
};
16-
typedef basic_string<char> string;
17-
}
1+
#include "../taint-tests/stl.h"
182

193
// BDE spells the standard string as `bsl::string`; alias it onto the stub above.
204
namespace bsl {

‎cpp/ql/test/library-tests/dataflow/external-models/flow.expected‎

Lines changed: 1268 additions & 1155 deletions
Large diffs are not rendered by default.

‎cpp/ql/test/library-tests/dataflow/external-models/protobuf.cpp‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11

22
// --- stub library headers ---
33

4-
#include "std_string.h"
5-
6-
namespace std {
7-
class istream {
8-
public:
9-
istream();
10-
};
11-
12-
class ostream {
13-
public:
14-
ostream();
15-
};
16-
}
4+
#include "../taint-tests/stl.h"
175

186
namespace absl {
197
class string_view {

‎cpp/ql/test/library-tests/dataflow/external-models/sinks.expected‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| asio_streams.cpp:122:29:122:39 | recv_buffer | remote-sink |
2-
| asio_streams.cpp:132:29:132:39 | send_buffer | remote-sink |
1+
| asio_streams.cpp:115:29:115:39 | recv_buffer | remote-sink |
2+
| asio_streams.cpp:125:29:125:39 | send_buffer | remote-sink |
33
| test.cpp:12:10:12:10 | 0 | test-sink |
44
| test.cpp:14:10:14:10 | x | test-sink |
55
| test.cpp:18:10:18:10 | y | test-sink |

‎cpp/ql/test/library-tests/dataflow/external-models/sources.expected‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
| asio_streams.cpp:116:34:116:44 | read_until output argument | remote |
2-
| azure.cpp:286:48:286:60 | call to GetBodyStream | remote |
3-
| azure.cpp:306:52:306:61 | call to GetHeaders | remote |
4-
| azure.cpp:310:38:310:44 | call to GetBody | remote |
5-
| azure.cpp:314:68:314:84 | call to ExtractBodyStream | remote |
6-
| azure.cpp:323:32:323:40 | call to GetHeader | remote |
7-
| azure.cpp:327:58:327:67 | call to GetHeaders | remote |
8-
| azure.cpp:336:34:336:43 | call to GetHeaders | remote |
1+
| asio_streams.cpp:109:34:109:44 | read_until output argument | remote |
2+
| azure.cpp:216:48:216:60 | call to GetBodyStream | remote |
3+
| azure.cpp:236:52:236:61 | call to GetHeaders | remote |
4+
| azure.cpp:240:38:240:44 | call to GetBody | remote |
5+
| azure.cpp:244:68:244:84 | call to ExtractBodyStream | remote |
6+
| azure.cpp:253:32:253:40 | call to GetHeader | remote |
7+
| azure.cpp:257:58:257:67 | call to GetHeaders | remote |
8+
| azure.cpp:266:34:266:43 | call to GetHeaders | remote |
99
| test.cpp:10:10:10:18 | call to ymlSource | local |
1010
| test.cpp:56:8:56:16 | call to ymlSource | local |
1111
| test.cpp:94:10:94:18 | call to ymlSource | local |

‎cpp/ql/test/library-tests/dataflow/external-models/std_string.h‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)