Skip to content

Commit 62c432f

Browse files
committed
C++: Tabs -> Spaces.
1 parent ff4c63f commit 62c432f

File tree

1 file changed

+130
-130
lines changed
  • cpp/ql/test/query-tests/Security/CWE/CWE-416/semmle/tests/UseOfStringAfterLifetimeEnds

1 file changed

+130
-130
lines changed
Lines changed: 130 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,155 @@
11
typedef unsigned long size_t;
22

33
namespace std {
4-
template<class T> struct remove_reference { typedef T type; };
4+
template<class T> struct remove_reference { typedef T type; };
55

6-
template<class T> struct remove_reference<T &> { typedef T type; };
6+
template<class T> struct remove_reference<T &> { typedef T type; };
77

8-
template<class T> struct remove_reference<T &&> { typedef T type; };
8+
template<class T> struct remove_reference<T &&> { typedef T type; };
99

10-
template<class T> using remove_reference_t = typename remove_reference<T>::type;
10+
template<class T> using remove_reference_t = typename remove_reference<T>::type;
1111

12-
template< class T > std::remove_reference_t<T>&& move( T&& t );
12+
template< class T > std::remove_reference_t<T>&& move( T&& t );
1313
}
1414

1515
// --- iterator ---
1616

1717
namespace std {
18-
template<class T> struct remove_const { typedef T type; };
19-
20-
template<class T> struct remove_const<const T> { typedef T type; };
21-
22-
// `remove_const_t<T>` removes any `const` specifier from `T`
23-
template<class T> using remove_const_t = typename remove_const<T>::type;
24-
25-
struct ptrdiff_t;
26-
27-
template<class I> struct iterator_traits;
28-
29-
template <class Category,
30-
class value_type,
31-
class difference_type = ptrdiff_t,
32-
class pointer_type = value_type*,
33-
class reference_type = value_type&>
34-
struct iterator {
35-
typedef Category iterator_category;
36-
37-
iterator();
38-
iterator(iterator<Category, remove_const_t<value_type> > const &other); // non-const -> const conversion constructor
39-
40-
iterator &operator++();
41-
iterator operator++(int);
42-
iterator &operator--();
43-
iterator operator--(int);
44-
bool operator==(iterator other) const;
45-
bool operator!=(iterator other) const;
46-
reference_type operator*() const;
47-
pointer_type operator->() const;
48-
iterator operator+(int);
49-
iterator operator-(int);
50-
iterator &operator+=(int);
51-
iterator &operator-=(int);
52-
int operator-(iterator);
53-
reference_type operator[](int);
54-
};
55-
56-
struct input_iterator_tag {};
57-
struct forward_iterator_tag : public input_iterator_tag {};
58-
struct bidirectional_iterator_tag : public forward_iterator_tag {};
59-
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
18+
template<class T> struct remove_const { typedef T type; };
19+
20+
template<class T> struct remove_const<const T> { typedef T type; };
21+
22+
// `remove_const_t<T>` removes any `const` specifier from `T`
23+
template<class T> using remove_const_t = typename remove_const<T>::type;
24+
25+
struct ptrdiff_t;
26+
27+
template<class I> struct iterator_traits;
28+
29+
template <class Category,
30+
class value_type,
31+
class difference_type = ptrdiff_t,
32+
class pointer_type = value_type*,
33+
class reference_type = value_type&>
34+
struct iterator {
35+
typedef Category iterator_category;
36+
37+
iterator();
38+
iterator(iterator<Category, remove_const_t<value_type> > const &other); // non-const -> const conversion constructor
39+
40+
iterator &operator++();
41+
iterator operator++(int);
42+
iterator &operator--();
43+
iterator operator--(int);
44+
bool operator==(iterator other) const;
45+
bool operator!=(iterator other) const;
46+
reference_type operator*() const;
47+
pointer_type operator->() const;
48+
iterator operator+(int);
49+
iterator operator-(int);
50+
iterator &operator+=(int);
51+
iterator &operator-=(int);
52+
int operator-(iterator);
53+
reference_type operator[](int);
54+
};
55+
56+
struct input_iterator_tag {};
57+
struct forward_iterator_tag : public input_iterator_tag {};
58+
struct bidirectional_iterator_tag : public forward_iterator_tag {};
59+
struct random_access_iterator_tag : public bidirectional_iterator_tag {};
6060
}
6161

6262
// --- string ---
6363

6464
namespace std
6565
{
66-
template<class charT> struct char_traits;
67-
68-
typedef size_t streamsize;
69-
70-
template <class T> class allocator {
71-
public:
72-
allocator() throw();
73-
typedef size_t size_type;
74-
};
75-
76-
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
77-
class basic_string {
78-
public:
79-
using value_type = charT;
80-
using reference = value_type&;
81-
using const_reference = const value_type&;
82-
typedef typename Allocator::size_type size_type;
83-
static const size_type npos = -1;
84-
85-
explicit basic_string(const Allocator& a = Allocator());
86-
basic_string(const charT* s, const Allocator& a = Allocator());
87-
template<class InputIterator> basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
88-
89-
const charT* c_str() const;
90-
charT* data() noexcept;
91-
size_t length() const;
92-
93-
typedef std::iterator<random_access_iterator_tag, charT> iterator;
94-
typedef std::iterator<random_access_iterator_tag, const charT> const_iterator;
95-
96-
iterator begin();
97-
iterator end();
98-
const_iterator begin() const;
99-
const_iterator end() const;
100-
const_iterator cbegin() const;
101-
const_iterator cend() const;
102-
103-
const_reference operator[](size_type pos) const;
104-
reference operator[](size_type pos);
105-
const_reference at(size_type n) const;
106-
reference at(size_type n);
107-
basic_string& insert(size_type pos, const basic_string& str);
108-
basic_string& insert(size_type pos, size_type n, charT c);
109-
basic_string& insert(size_type pos, const charT* s);
110-
iterator insert(const_iterator p, size_type n, charT c);
111-
template<class InputIterator> iterator insert(const_iterator p, InputIterator first, InputIterator last);
112-
basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
113-
basic_string& replace(size_type pos1, size_type n1, size_type n2, charT c);
114-
};
115-
116-
template<class charT, class traits, class Allocator> basic_string<charT, traits, Allocator> operator+(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs);
117-
template<class charT, class traits, class Allocator> basic_string<charT, traits, Allocator> operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
118-
119-
typedef basic_string<char> string;
66+
template<class charT> struct char_traits;
67+
68+
typedef size_t streamsize;
69+
70+
template <class T> class allocator {
71+
public:
72+
allocator() throw();
73+
typedef size_t size_type;
74+
};
75+
76+
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
77+
class basic_string {
78+
public:
79+
using value_type = charT;
80+
using reference = value_type&;
81+
using const_reference = const value_type&;
82+
typedef typename Allocator::size_type size_type;
83+
static const size_type npos = -1;
84+
85+
explicit basic_string(const Allocator& a = Allocator());
86+
basic_string(const charT* s, const Allocator& a = Allocator());
87+
template<class InputIterator> basic_string(InputIterator begin, InputIterator end, const Allocator& a = Allocator());
88+
89+
const charT* c_str() const;
90+
charT* data() noexcept;
91+
size_t length() const;
92+
93+
typedef std::iterator<random_access_iterator_tag, charT> iterator;
94+
typedef std::iterator<random_access_iterator_tag, const charT> const_iterator;
95+
96+
iterator begin();
97+
iterator end();
98+
const_iterator begin() const;
99+
const_iterator end() const;
100+
const_iterator cbegin() const;
101+
const_iterator cend() const;
102+
103+
const_reference operator[](size_type pos) const;
104+
reference operator[](size_type pos);
105+
const_reference at(size_type n) const;
106+
reference at(size_type n);
107+
basic_string& insert(size_type pos, const basic_string& str);
108+
basic_string& insert(size_type pos, size_type n, charT c);
109+
basic_string& insert(size_type pos, const charT* s);
110+
iterator insert(const_iterator p, size_type n, charT c);
111+
template<class InputIterator> iterator insert(const_iterator p, InputIterator first, InputIterator last);
112+
basic_string& replace(size_type pos1, size_type n1, const basic_string& str);
113+
basic_string& replace(size_type pos1, size_type n1, size_type n2, charT c);
114+
};
115+
116+
template<class charT, class traits, class Allocator> basic_string<charT, traits, Allocator> operator+(const basic_string<charT, traits, Allocator>& lhs, const basic_string<charT, traits, Allocator>& rhs);
117+
template<class charT, class traits, class Allocator> basic_string<charT, traits, Allocator> operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs);
118+
119+
typedef basic_string<char> string;
120120
}
121121

122122
// --- vector ---
123123

124124
namespace std {
125-
template<class T, class Allocator = allocator<T>>
126-
class vector {
127-
public:
128-
using value_type = T;
129-
using reference = value_type&;
130-
using const_reference = const value_type&;
131-
using size_type = unsigned int;
132-
using iterator = std::iterator<random_access_iterator_tag, T>;
133-
using const_iterator = std::iterator<random_access_iterator_tag, const T>;
134-
135-
vector() noexcept(noexcept(Allocator()));
136-
explicit vector(const Allocator&) noexcept;
137-
explicit vector(size_type n, const Allocator& = Allocator());
138-
vector(size_type n, const T& value, const Allocator& = Allocator());
139-
template<class InputIterator, class IteratorCategory = typename InputIterator::iterator_category> vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
140-
~vector();
141-
142-
void push_back(const T& x);
143-
void push_back(T&& x);
144-
145-
iterator insert(const_iterator position, const T& x);
146-
iterator insert(const_iterator position, T&& x);
147-
iterator insert(const_iterator position, size_type n, const T& x);
148-
template<class InputIterator> iterator insert(const_iterator position, InputIterator first, InputIterator last);
149-
150-
template <class... Args> iterator emplace (const_iterator position, Args&&... args);
151-
template <class... Args> void emplace_back (Args&&... args);
152-
};
125+
template<class T, class Allocator = allocator<T>>
126+
class vector {
127+
public:
128+
using value_type = T;
129+
using reference = value_type&;
130+
using const_reference = const value_type&;
131+
using size_type = unsigned int;
132+
using iterator = std::iterator<random_access_iterator_tag, T>;
133+
using const_iterator = std::iterator<random_access_iterator_tag, const T>;
134+
135+
vector() noexcept(noexcept(Allocator()));
136+
explicit vector(const Allocator&) noexcept;
137+
explicit vector(size_type n, const Allocator& = Allocator());
138+
vector(size_type n, const T& value, const Allocator& = Allocator());
139+
template<class InputIterator, class IteratorCategory = typename InputIterator::iterator_category> vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
140+
~vector();
141+
142+
void push_back(const T& x);
143+
void push_back(T&& x);
144+
145+
iterator insert(const_iterator position, const T& x);
146+
iterator insert(const_iterator position, T&& x);
147+
iterator insert(const_iterator position, size_type n, const T& x);
148+
template<class InputIterator> iterator insert(const_iterator position, InputIterator first, InputIterator last);
149+
150+
template <class... Args> iterator emplace (const_iterator position, Args&&... args);
151+
template <class... Args> void emplace_back (Args&&... args);
152+
};
153153
}
154154

155155
struct S {
@@ -182,7 +182,7 @@ const char* test(bool b1, bool b2) {
182182

183183
S s5[] = { { std::string("hello").c_str() } }; // BAD
184184

185-
char c = std::string("hello").c_str()[0]; // GOOD
185+
char c = std::string("hello").c_str()[0]; // GOOD
186186

187187
return std::string("hello").c_str(); // BAD
188188
}

0 commit comments

Comments
 (0)