| 1 |
// PR 39548 verify ssa ICE |
| 2 |
// |
| 3 |
// { dg-do compile { target { lp64 } } } |
| 4 |
// { dg-options "-Wno-error -fno-exceptions -fno-tree-vrp -O2 -fprofile-generate -finline-limit=500 -std=c++98" } |
| 5 |
// { dg-additional-options "-Wno-return-type" } |
| 6 |
// { dg-skip-if "requires hosted libstdc++ for map" { ! hostedlib } } |
| 7 |
|
| 8 |
#include <map> |
| 9 |
#include <vector> |
| 10 |
#include <iostream> |
| 11 |
#include <cstdlib> |
| 12 |
|
| 13 |
#ifdef ERROR |
| 14 |
#undef ERROR |
| 15 |
#endif |
| 16 |
|
| 17 |
using namespace std; |
| 18 |
template<typename _FIter, typename _Tp> _FIter lower_bound(_FIter, _FIter, _Tp&); |
| 19 |
template<class _Key> struct hash { }; |
| 20 |
template<class _Val> struct _Hashtable_node { |
| 21 |
_Hashtable_node* _M_next; |
| 22 |
_Val _M_val; |
| 23 |
}; |
| 24 |
static const unsigned long __stl_prime_list[] = { 2, 3, 5 }; |
| 25 |
inline unsigned long prime(unsigned long __n) { |
| 26 |
const unsigned long* __first = __stl_prime_list; |
| 27 |
const unsigned long* __last = __stl_prime_list + 29; |
| 28 |
const unsigned long* pos = lower_bound(__first, __last, __n); |
| 29 |
return pos == __last ? *(__last - 1) : *pos; |
| 30 |
} |
| 31 |
template<class _Val, class _Key, class _HashFcn, class _ExtractKey, class _EqualKey, class _Alloc> struct hashtable { |
| 32 |
typedef _Key key_type; |
| 33 |
typedef _Val value_type; |
| 34 |
typedef _HashFcn hasher; |
| 35 |
typedef _EqualKey key_equal; |
| 36 |
typedef size_t size_type; |
| 37 |
typedef value_type& reference; |
| 38 |
typedef _Hashtable_node<_Val> _Node; |
| 39 |
typedef typename _Alloc::template rebind<value_type>::other allocator_type; |
| 40 |
allocator_type get_allocator() const { } |
| 41 |
typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc; |
| 42 |
typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc; |
| 43 |
typedef vector<_Node*, _Nodeptr_Alloc> _Vector_type; |
| 44 |
_Node_Alloc _M_node_allocator; |
| 45 |
void _M_put_node(_Node* __p) { |
| 46 |
_M_node_allocator.deallocate(__p, 1); |
| 47 |
} |
| 48 |
hasher _M_hash; |
| 49 |
key_equal _M_equals; |
| 50 |
_ExtractKey _M_get_key; |
| 51 |
_Vector_type _M_buckets; |
| 52 |
size_type _M_num_elements; |
| 53 |
hashtable(size_type __n, const _HashFcn& __hf, const _EqualKey& __eql, const allocator_type& __a = allocator_type()) : _M_num_elements(0) { |
| 54 |
_M_initialize_buckets(__n); |
| 55 |
} |
| 56 |
~hashtable() { clear(); } |
| 57 |
reference find_or_insert(const value_type& __obj); |
| 58 |
size_type count(const key_type& __key) const { |
| 59 |
const size_type __n = _M_bkt_num_key(__key); |
| 60 |
size_type __result = 0; |
| 61 |
for (const _Node* __cur = _M_buckets[__n]; __cur; __cur = __cur->_M_next) |
| 62 |
if (_M_equals(_M_get_key(__cur->_M_val), __key)) ++__result; |
| 63 |
} |
| 64 |
size_type erase(const key_type& __key); |
| 65 |
void clear(); |
| 66 |
size_type _M_next_size(size_type __n) const { return prime(__n); } |
| 67 |
void _M_initialize_buckets(size_type __n) { |
| 68 |
const size_type __n_buckets = _M_next_size(__n); |
| 69 |
_M_buckets.reserve(__n_buckets); |
| 70 |
_M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*) 0); |
| 71 |
} |
| 72 |
size_type _M_bkt_num_key(const key_type& __key) const { |
| 73 |
return _M_bkt_num_key(__key, _M_buckets.size()); |
| 74 |
} |
| 75 |
size_type _M_bkt_num_key(const key_type& __key, size_t __n) const { |
| 76 |
return _M_hash(__key) % __n; |
| 77 |
} |
| 78 |
void _M_delete_node(_Node* __n) { |
| 79 |
this->get_allocator().destroy(&__n->_M_val); |
| 80 |
_M_put_node(__n); |
| 81 |
} |
| 82 |
}; |
| 83 |
template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::size_type hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: erase(const key_type& __key) { |
| 84 |
const size_type __n = _M_bkt_num_key(__key); |
| 85 |
_Node* __first = _M_buckets[__n]; |
| 86 |
if (__first) _Node* __cur = __first; |
| 87 |
} |
| 88 |
template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All> void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>:: clear() { |
| 89 |
for (size_type __i = 0; __i < _M_buckets.size(); ++__i) { |
| 90 |
_Node* __cur = _M_buckets[__i]; |
| 91 |
while (__cur != 0) { _M_delete_node(__cur); } |
| 92 |
} |
| 93 |
} |
| 94 |
template<class _Key, class _Tp, class _HashFn = ::hash<_Key>, class _EqualKey = equal_to<_Key>, class _Alloc = allocator<_Tp> > struct hash_map { |
| 95 |
typedef hashtable<pair<const _Key, _Tp>,_Key, _HashFn, _Select1st<pair<const _Key, _Tp> >, _EqualKey, _Alloc> _Ht; |
| 96 |
_Ht _M_ht; |
| 97 |
typedef typename _Ht::key_type key_type; |
| 98 |
typedef typename _Ht::value_type value_type; |
| 99 |
typedef typename _Ht::hasher hasher; |
| 100 |
typedef typename _Ht::key_equal key_equal; |
| 101 |
typedef typename _Ht::size_type size_type; |
| 102 |
typedef typename _Ht::allocator_type allocator_type; |
| 103 |
hash_map() : _M_ht(100, hasher(), key_equal(), allocator_type()) { } |
| 104 |
_Tp& operator[](const key_type& __key) { |
| 105 |
return _M_ht.find_or_insert(value_type(__key, _Tp())).second; |
| 106 |
} |
| 107 |
size_type count(const key_type& __key) const { return _M_ht.count(__key); } |
| 108 |
size_type erase(const key_type& __key) { |
| 109 |
return _M_ht.erase(__key); |
| 110 |
} |
| 111 |
}; |
| 112 |
extern size_t strlen (__const char *__s); |
| 113 |
template <class C> struct scoped_ptr { |
| 114 |
explicit scoped_ptr(C* p = __null) : ptr_(p) { delete ptr_; } |
| 115 |
void reset(C* p = __null) { |
| 116 |
if (p != ptr_) { delete ptr_; } |
| 117 |
} |
| 118 |
C& operator*() const {} |
| 119 |
C* operator->() const {} |
| 120 |
bool operator==(C* p) const { return ptr_ == p; } |
| 121 |
bool operator!=(C* p) const { return ptr_ != p; } |
| 122 |
C* ptr_; |
| 123 |
}; |
| 124 |
namespace std { |
| 125 |
class strstreambuf : public basic_streambuf<char, char_traits<char> > { |
| 126 |
}; |
| 127 |
class strstream : public basic_iostream<char> { |
| 128 |
public: int pcount() const; |
| 129 |
char* str(); |
| 130 |
strstreambuf _M_buf; |
| 131 |
}; |
| 132 |
}; |
| 133 |
const int INFO = 0, WARNING = 1, ERROR = 2, FATAL = 3, NUM_SEVERITIES = 4; |
| 134 |
struct foo_1 { |
| 135 |
foo_1(string* str) : str_(str) { } |
| 136 |
operator bool() const { |
| 137 |
return (__builtin_expect(str_ != __null, 0)); |
| 138 |
} |
| 139 |
string* str_; |
| 140 |
}; |
| 141 |
template<class t1, class t2> string* Makefoo_1(const t1& v1, const t2& v2, const char* names) { |
| 142 |
strstream ss; |
| 143 |
ss << names << " (" << v1 << " vs. " << v2 << ")"; |
| 144 |
return new string(ss.str(), ss.pcount()); |
| 145 |
} |
| 146 |
template <class t1, class t2> inline string* Check_GTImpl(const t1& v1, const t2& v2, const char* names) { |
| 147 |
if (v1 > v2) return __null; |
| 148 |
else return Makefoo_1(v1, v2, names); |
| 149 |
} |
| 150 |
struct blah_54 { |
| 151 |
blah_54(const char* file, int line, int severity); |
| 152 |
~blah_54(); |
| 153 |
ostream& stream() { }; |
| 154 |
}; |
| 155 |
class blah_0 : public blah_54 { |
| 156 |
public: blah_0(const char* file, int line); |
| 157 |
blah_0(const char* file, int line, const foo_1& result); |
| 158 |
}; |
| 159 |
template <class Value, class Key, class HashFcn, class ExtractKey, class EqualKey, class Alloc> class dense_hashtable; |
| 160 |
template <class V, class K, class HF, class ExK, class EqK, class A> struct dense_hashtable_iterator { |
| 161 |
typedef V* pointer; |
| 162 |
dense_hashtable_iterator(const dense_hashtable<V,K,HF,ExK,EqK,A> *h, pointer it, pointer it_end, bool advance) : ht(h), pos(it), end(it_end) { |
| 163 |
if (advance) advance_past_empty_and_deleted(); |
| 164 |
} |
| 165 |
pointer operator->() const { } |
| 166 |
void advance_past_empty_and_deleted() { |
| 167 |
while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this)) ) ++pos; |
| 168 |
} |
| 169 |
const dense_hashtable<V,K,HF,ExK,EqK,A> *ht; |
| 170 |
pointer pos, end; |
| 171 |
}; |
| 172 |
template <class V, class K, class HF, class ExK, class EqK, class A> struct dense_hashtable_const_iterator { |
| 173 |
typedef dense_hashtable_iterator<V,K,HF,ExK,EqK,A> iterator; |
| 174 |
typedef dense_hashtable_const_iterator<V,K,HF,ExK,EqK,A> const_iterator; |
| 175 |
typedef const V& reference; |
| 176 |
typedef const V* pointer; |
| 177 |
dense_hashtable_const_iterator(const dense_hashtable<V,K,HF,ExK,EqK,A> *h, pointer it, pointer it_end, bool advance) : ht(h), pos(it), end(it_end) { |
| 178 |
if (advance) advance_past_empty_and_deleted(); |
| 179 |
} |
| 180 |
dense_hashtable_const_iterator(const iterator &it) : pos(it.pos), end(it.end) {} |
| 181 |
reference operator*() const { return *pos; } |
| 182 |
pointer operator->() const {} |
| 183 |
void advance_past_empty_and_deleted() { |
| 184 |
while ( pos != end && (ht->test_empty(*this) || ht->test_deleted(*this))) ++pos; |
| 185 |
} |
| 186 |
const_iterator& operator++() { } |
| 187 |
bool operator!=(const const_iterator& it) const { } |
| 188 |
const dense_hashtable<V,K,HF,ExK,EqK,A> *ht; |
| 189 |
pointer pos, end; |
| 190 |
}; |
| 191 |
template <class Value, class Key, class HashFcn, class ExtractKey, class EqualKey, class Alloc> class dense_hashtable { |
| 192 |
public: typedef Key key_type; |
| 193 |
typedef Value value_type; |
| 194 |
typedef HashFcn hasher; |
| 195 |
typedef EqualKey key_equal; |
| 196 |
typedef size_t size_type; |
| 197 |
typedef dense_hashtable_iterator<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc> iterator; |
| 198 |
typedef dense_hashtable_const_iterator<Value, Key, HashFcn, ExtractKey, EqualKey, Alloc> const_iterator; |
| 199 |
static const float HT_OCCUPANCY_FLT; |
| 200 |
static const float HT_EMPTY_FLT; |
| 201 |
static const size_t HT_MIN_BUCKETS = 32; |
| 202 |
iterator end() { |
| 203 |
return iterator(this, table + num_buckets, table + num_buckets, true); |
| 204 |
} |
| 205 |
const_iterator end() const { |
| 206 |
return const_iterator(this, table + num_buckets, table+num_buckets,true); |
| 207 |
} |
| 208 |
void set_value(value_type* dst, const value_type& src) { |
| 209 |
new(dst) value_type(src); |
| 210 |
} |
| 211 |
void destroy_buckets(size_type first, size_type last) { |
| 212 |
for (; first != last; ++first) table[first].~value_type(); |
| 213 |
} |
| 214 |
private: void squash_deleted() { |
| 215 |
if ( num_deleted ) { |
| 216 |
dense_hashtable tmp(*this); |
| 217 |
swap(tmp); |
| 218 |
} |
| 219 |
} |
| 220 |
public: void set_deleted_key(const value_type &val) { squash_deleted(); } |
| 221 |
bool test_deleted(size_type bucknum) const { |
| 222 |
return (use_deleted && num_deleted > 0 && equals(get_key(delval), get_key(table[bucknum]))); |
| 223 |
} |
| 224 |
bool test_deleted(const const_iterator &it) const { |
| 225 |
return (use_deleted && num_deleted > 0 && equals(get_key(delval), get_key(*it))); |
| 226 |
} |
| 227 |
bool set_deleted(const_iterator &it) { |
| 228 |
set_value(const_cast<value_type*>(&(*it)), delval); |
| 229 |
} |
| 230 |
bool test_empty(size_type bucknum) const { |
| 231 |
return equals(get_key(emptyval), get_key(table[bucknum])); |
| 232 |
} |
| 233 |
bool test_empty(const const_iterator &it) const { |
| 234 |
return equals(get_key(emptyval), get_key(*it)); |
| 235 |
} |
| 236 |
void fill_range_with_empty(value_type* table_start, value_type* table_end) { |
| 237 |
uninitialized_fill(table_start, table_end, emptyval); |
| 238 |
} |
| 239 |
void set_empty(size_type buckstart, size_type buckend) { |
| 240 |
destroy_buckets(buckstart, buckend); |
| 241 |
fill_range_with_empty(table + buckstart, table + buckend); |
| 242 |
} |
| 243 |
size_type size() const { |
| 244 |
return num_elements - num_deleted; |
| 245 |
} |
| 246 |
size_type bucket_count() const { } |
| 247 |
static const size_type ILLEGAL_BUCKET = size_type(-1); |
| 248 |
size_type min_size(size_type num_elts, size_type min_buckets_wanted) { |
| 249 |
size_type sz = HT_MIN_BUCKETS; |
| 250 |
while ( sz < min_buckets_wanted || num_elts >= sz * enlarge_resize_percent ) sz *= 2; |
| 251 |
} |
| 252 |
void maybe_shrink() { |
| 253 |
if (shrink_threshold > 0 && (num_elements-num_deleted) < shrink_threshold && bucket_count() > HT_MIN_BUCKETS ) { |
| 254 |
size_type sz = bucket_count() / 2; |
| 255 |
sz /= 2; |
| 256 |
dense_hashtable tmp(*this, sz); |
| 257 |
swap(tmp); |
| 258 |
} |
| 259 |
} |
| 260 |
void resize_delta(size_type delta, size_type min_buckets_wanted = 0) { |
| 261 |
if ( consider_shrink ) maybe_shrink(); |
| 262 |
const size_type needed_size = min_size(num_elements + delta, min_buckets_wanted); |
| 263 |
if ( needed_size > bucket_count() ) { |
| 264 |
const size_type resize_to = min_size(num_elements - num_deleted + delta, min_buckets_wanted); |
| 265 |
dense_hashtable tmp(*this, resize_to); |
| 266 |
swap(tmp); |
| 267 |
} |
| 268 |
} |
| 269 |
void copy_from(const dense_hashtable &ht, size_type min_buckets_wanted = 0) { |
| 270 |
clear(); |
| 271 |
const size_type resize_to = min_size(ht.size(), min_buckets_wanted); |
| 272 |
num_elements++; |
| 273 |
} |
| 274 |
explicit dense_hashtable(size_type n = 0, const HashFcn& hf = HashFcn(), const EqualKey& eql = EqualKey(),const ExtractKey& ext = ExtractKey()) : num_deleted(0), use_deleted(false), use_empty(false), delval(), emptyval(), enlarge_resize_percent(HT_OCCUPANCY_FLT), shrink_resize_percent(HT_EMPTY_FLT), table(__null), num_buckets(min_size(0, n)), num_elements(0) { |
| 275 |
reset_thresholds(); |
| 276 |
} |
| 277 |
dense_hashtable(const dense_hashtable& ht, size_type min_buckets_wanted = 0) : num_deleted(0), use_deleted(ht.use_deleted), use_empty(ht.use_empty), delval(ht.delval), emptyval(ht.emptyval), enlarge_resize_percent(ht.enlarge_resize_percent), shrink_resize_percent(ht.shrink_resize_percent), table(__null), num_buckets(0), num_elements(0) { |
| 278 |
reset_thresholds(); |
| 279 |
copy_from(ht, min_buckets_wanted); |
| 280 |
set_value(&emptyval, ht.emptyval); |
| 281 |
enlarge_resize_percent = ht.enlarge_resize_percent; |
| 282 |
copy_from(ht); |
| 283 |
} |
| 284 |
~dense_hashtable() { |
| 285 |
if (table) { |
| 286 |
destroy_buckets(0, num_buckets); |
| 287 |
free(table); |
| 288 |
} |
| 289 |
} |
| 290 |
void swap(dense_hashtable& ht) { |
| 291 |
std::swap(equals, ht.equals); |
| 292 |
{ |
| 293 |
value_type tmp; |
| 294 |
set_value(&delval, ht.delval); |
| 295 |
set_value(&ht.delval, tmp); |
| 296 |
set_value(&ht.emptyval, tmp); |
| 297 |
} |
| 298 |
std::swap(table, ht.table); |
| 299 |
std::swap(num_buckets, ht.num_buckets); |
| 300 |
reset_thresholds(); |
| 301 |
ht.reset_thresholds(); |
| 302 |
} |
| 303 |
void clear() { |
| 304 |
if (table) destroy_buckets(0, num_buckets); |
| 305 |
num_buckets = min_size(0,0); |
| 306 |
set_empty(0, num_buckets); |
| 307 |
} |
| 308 |
pair<size_type, size_type> find_position(const key_type &key) const { |
| 309 |
const size_type bucket_count_minus_one = bucket_count() - 1; |
| 310 |
size_type bucknum = hash(key) & bucket_count_minus_one; |
| 311 |
size_type insert_pos = ILLEGAL_BUCKET; |
| 312 |
while ( 1 ) { |
| 313 |
if ( test_empty(bucknum) ) { |
| 314 |
if ( insert_pos == ILLEGAL_BUCKET ) return pair<size_type,size_type>(ILLEGAL_BUCKET, insert_pos); |
| 315 |
} |
| 316 |
else if ( test_deleted(bucknum) ) { |
| 317 |
if ( insert_pos == ILLEGAL_BUCKET ) insert_pos = bucknum; |
| 318 |
} |
| 319 |
else if ( equals(key, get_key(table[bucknum])) ) { |
| 320 |
return pair<size_type,size_type>(bucknum, ILLEGAL_BUCKET); |
| 321 |
} |
| 322 |
} |
| 323 |
} |
| 324 |
iterator find(const key_type& key) { |
| 325 |
if ( size() == 0 ) return end(); |
| 326 |
pair<size_type, size_type> pos = find_position(key); |
| 327 |
if ( pos.first == ILLEGAL_BUCKET ) return end(); |
| 328 |
return iterator(this, table + pos.first, table + num_buckets, false); |
| 329 |
} |
| 330 |
const_iterator find(const key_type& key) const { |
| 331 |
if ( size() == 0 ) return end(); |
| 332 |
pair<size_type, size_type> pos = find_position(key); |
| 333 |
if ( pos.first == ILLEGAL_BUCKET ) return end(); |
| 334 |
return const_iterator(this, table + pos.first, table+num_buckets, false); |
| 335 |
} |
| 336 |
size_type count(const key_type &key) const { |
| 337 |
pair<size_type, size_type> pos = find_position(key); } |
| 338 |
pair<iterator, bool> insert_noresize(const value_type& obj) { |
| 339 |
const pair<size_type,size_type> pos = find_position(get_key(obj)); |
| 340 |
if ( pos.first != ILLEGAL_BUCKET) { |
| 341 |
return pair<iterator,bool>(iterator(this, table + pos.first, table + num_buckets, false), false); |
| 342 |
} |
| 343 |
else { |
| 344 |
if ( test_deleted(pos.second) ) { ++num_elements; } |
| 345 |
return pair<iterator,bool>(iterator(this, table + pos.second, table + num_buckets, false), true); |
| 346 |
} |
| 347 |
} |
| 348 |
pair<iterator, bool> insert(const value_type& obj) { |
| 349 |
resize_delta(1); |
| 350 |
return insert_noresize(obj); |
| 351 |
} |
| 352 |
size_type erase(const key_type& key) { |
| 353 |
const_iterator pos = find(key); |
| 354 |
if ( pos != end() ) { |
| 355 |
set_deleted(pos); |
| 356 |
} |
| 357 |
} |
| 358 |
hasher hash; |
| 359 |
key_equal equals; |
| 360 |
ExtractKey get_key; |
| 361 |
size_type num_deleted; |
| 362 |
bool use_deleted; |
| 363 |
bool use_empty; |
| 364 |
value_type delval; |
| 365 |
value_type emptyval; |
| 366 |
float enlarge_resize_percent; |
| 367 |
float shrink_resize_percent; |
| 368 |
size_type shrink_threshold; |
| 369 |
size_type enlarge_threshold; |
| 370 |
value_type *table; |
| 371 |
size_type num_buckets; |
| 372 |
size_type num_elements; |
| 373 |
bool consider_shrink; |
| 374 |
void reset_thresholds() { |
| 375 |
enlarge_threshold = static_cast<size_type>(num_buckets * shrink_resize_percent); |
| 376 |
} |
| 377 |
}; |
| 378 |
template<> struct hash<long> { |
| 379 |
size_t operator()(long x) const { |
| 380 |
} |
| 381 |
}; |
| 382 |
template<> struct hash<unsigned long> { |
| 383 |
size_t operator()(unsigned long x) const { |
| 384 |
} |
| 385 |
}; |
| 386 |
template <class Key, class T, class HashFcn = hash<Key>, class EqualKey = equal_to<Key>, class Alloc = allocator<T> > class dense_hash_map { |
| 387 |
struct SelectKey { |
| 388 |
const Key& operator()(const pair<const Key, T>& p) const { |
| 389 |
return p.first; |
| 390 |
} |
| 391 |
}; |
| 392 |
typedef dense_hashtable<pair<const Key, T>, Key, HashFcn, SelectKey, EqualKey, Alloc> ht; |
| 393 |
ht rep; |
| 394 |
public: typedef typename ht::key_type key_type; |
| 395 |
typedef T data_type; |
| 396 |
typedef typename ht::value_type value_type; |
| 397 |
typedef typename ht::size_type size_type; |
| 398 |
typedef typename ht::iterator iterator; |
| 399 |
typedef typename ht::const_iterator const_iterator; |
| 400 |
iterator end() { |
| 401 |
return rep.end(); |
| 402 |
} |
| 403 |
iterator find(const key_type& key) { return rep.find(key); } |
| 404 |
data_type& operator[](const key_type& key) { |
| 405 |
iterator it = find(key); |
| 406 |
return insert(value_type(key, data_type())).first->second; |
| 407 |
} |
| 408 |
pair<iterator, bool> insert(const value_type& obj) { |
| 409 |
return rep.insert(obj); |
| 410 |
} |
| 411 |
void set_deleted_key(const key_type& key) { |
| 412 |
rep.set_deleted_key(value_type(key, data_type())); |
| 413 |
} |
| 414 |
size_type erase(const key_type& key) { return rep.erase(key); } |
| 415 |
}; |
| 416 |
template <class Value, class HashFcn = hash<Value>, class EqualKey = equal_to<Value>, class Alloc = allocator<Value> > class dense_hash_set { |
| 417 |
struct Identity { |
| 418 |
const Value& operator()(const Value& v) const { return v; } |
| 419 |
}; |
| 420 |
typedef dense_hashtable<Value, Value, HashFcn, Identity, EqualKey, Alloc> ht; |
| 421 |
ht rep; |
| 422 |
public: typedef typename ht::key_type key_type; |
| 423 |
typedef typename ht::value_type value_type; |
| 424 |
typedef typename ht::size_type size_type; |
| 425 |
typedef typename ht::const_iterator iterator; |
| 426 |
size_type count(const key_type& key) const { |
| 427 |
return rep.count(key); |
| 428 |
} |
| 429 |
pair<iterator, bool> insert(const value_type& obj) { |
| 430 |
pair<typename ht::iterator, bool> p = rep.insert(obj); |
| 431 |
} |
| 432 |
size_type erase(const key_type& key) { |
| 433 |
return rep.erase(key); |
| 434 |
} |
| 435 |
}; |
| 436 |
class linked_ptr_internal { |
| 437 |
public: bool depart() { if (next_ == this) return true; } |
| 438 |
mutable linked_ptr_internal const* next_; |
| 439 |
}; |
| 440 |
template <typename T> class linked_ptr { |
| 441 |
public: explicit linked_ptr(T* ptr = __null) { |
| 442 |
} |
| 443 |
~linked_ptr() { depart(); } |
| 444 |
T& operator*() const { } |
| 445 |
T* value_; |
| 446 |
linked_ptr_internal link_; |
| 447 |
void depart() { |
| 448 |
if (link_.depart()) delete value_; |
| 449 |
} |
| 450 |
}; |
| 451 |
class blah_3 { |
| 452 |
const char* ptr_; |
| 453 |
int length_; |
| 454 |
public: blah_3(const char* str) : ptr_(str), length_((str == __null) ? 0 : static_cast<int>(strlen(str))) { } |
| 455 |
}; |
| 456 |
class blah_5; |
| 457 |
class Bitmap { |
| 458 |
public: Bitmap(unsigned int size) : array_size_(RequiredArraySize(size)) { } |
| 459 |
static unsigned int RequiredArraySize(unsigned int num_bits) { return (num_bits + 31) >> 5; } |
| 460 |
unsigned int array_size_; |
| 461 |
}; |
| 462 |
enum blah_31 { CREATIVE_FORMAT_TEXT_NARROW, kNumblah_31s }; |
| 463 |
enum blah_33 { BLACKLISTED }; |
| 464 |
template <typename EnumT> class blah_55; |
| 465 |
typedef blah_55<blah_31> blah_31Set; |
| 466 |
enum blah_36 { APPROVAL_STATUS_APPROVED, APPROVAL_STATUS_UNKNOWN }; |
| 467 |
enum blah_37 { hahah_INVALID, hahah_KEYWORD }; |
| 468 |
template<typename EnumT> class blah_55 { |
| 469 |
public: blah_55(int enum_size); |
| 470 |
bool Insert(EnumT x); |
| 471 |
const int enum_size_; |
| 472 |
Bitmap elements_; |
| 473 |
}; |
| 474 |
template<typename EnumT> blah_55<EnumT>::blah_55(int enum_size) :enum_size_(enum_size), elements_(enum_size) { |
| 475 |
while (foo_1 _result = Check_GTImpl(1, 0, "enum_size" " " ">" " " "0")) blah_0(".h", 1902, _result).stream(); |
| 476 |
}; |
| 477 |
enum blah_38 { |
| 478 |
ttttttt_9, }; |
| 479 |
class blah_46 { |
| 480 |
public: blah_46() : hahaha_id_(0), type_(hahah_INVALID), approval_status_(APPROVAL_STATUS_APPROVED) { |
| 481 |
} |
| 482 |
blah_46(long cid) : hahaha_id_(cid), type_(hahah_INVALID), approval_status_(APPROVAL_STATUS_APPROVED) { |
| 483 |
} |
| 484 |
long id() const { |
| 485 |
return (static_cast<long>(hahaha_id_) << 16) >> 16; |
| 486 |
} |
| 487 |
static const blah_46 kBlacklistedID; |
| 488 |
bool operator == (const blah_46& x) const { return id() == x.id(); } |
| 489 |
bool operator < (const blah_46& x) const { return id() < x.id(); } |
| 490 |
long hahaha_id_ : 48; |
| 491 |
blah_37 type_ : 8; |
| 492 |
blah_36 approval_status_ : 4; |
| 493 |
}; |
| 494 |
template <> struct hash<blah_46> { |
| 495 |
size_t operator()(const blah_46 &x) const { |
| 496 |
return size_t(x.id()); |
| 497 |
} |
| 498 |
}; |
| 499 |
class blah_57 { |
| 500 |
public: blah_57(); |
| 501 |
void AddReason(blah_33 reason, const blah_3& debug_str, const blah_46& hahaha_id, bool ); |
| 502 |
void set_collects_multiple_reasons(bool t) { } |
| 503 |
private: struct foo_3 { |
| 504 |
string reject_desc; |
| 505 |
}; |
| 506 |
foo_3 first_reason_; |
| 507 |
}; |
| 508 |
template <class T> struct foo_5 : public unary_function<T*, long> { |
| 509 |
long operator()(const T* p) const { |
| 510 |
long id = reinterpret_cast<long>(p); |
| 511 |
if (id < 2) return -id; |
| 512 |
} |
| 513 |
}; |
| 514 |
template <class T> class DensePtrSet : public dense_hashtable<T*, long, hash<long>, foo_5<T>, equal_to<long>, allocator<T*> > { |
| 515 |
public: DensePtrSet() { |
| 516 |
this->set_deleted_key(reinterpret_cast<T*>(1)); |
| 517 |
} |
| 518 |
const T* Find(long key) const { |
| 519 |
typename DensePtrSet<T>::const_iterator it = this->find(key); |
| 520 |
return it != this->end() ? *it : __null; |
| 521 |
} |
| 522 |
}; |
| 523 |
struct foo_7 { |
| 524 |
foo_7(bool spell_correction, bool query_broadening, bool previous_query, bool near_aaaaa, bool same_length, float mult, float exp_score) : shengmo_0(spell_correction), shengmo_1(query_broadening), shengmo_2(previous_query), shengmo_3(near_aaaaa), shengmo_4(same_length), multiplier(mult), expansion_score(exp_score) { |
| 525 |
} |
| 526 |
int CompareSameKeywordMatch(const foo_7& compare) const; |
| 527 |
bool shengmo_0, shengmo_1, shengmo_2, shengmo_3, shengmo_4; |
| 528 |
float multiplier, expansion_score; |
| 529 |
}; |
| 530 |
enum blah_41 { |
| 531 |
ACP_ECPM_EARLY = 2 }; |
| 532 |
struct foo_8 { unsigned int packed_ctr1; }; |
| 533 |
struct foo_9 { foo_9() {}}; |
| 534 |
class blah_16; |
| 535 |
class blah_17; |
| 536 |
class foo_12 { public: foo_12() {} |
| 537 |
unsigned long hahaha_id() const {} |
| 538 |
unsigned int qbb_score() const {} |
| 539 |
private: static const vector<blah_46> hmmmmh_4; |
| 540 |
long hahaha_id_ : 40; |
| 541 |
}; |
| 542 |
class foo_13 { |
| 543 |
public: typedef dense_hash_map<long, int> BestMap; |
| 544 |
foo_13() { best_rrrrrrr_.set_deleted_key(-1); } |
| 545 |
void erase(long ad_group_id) { |
| 546 |
best_rrrrrrr_.erase(ad_group_id); |
| 547 |
} |
| 548 |
typedef BestMap::iterator iterator; |
| 549 |
typedef BestMap::const_iterator const_iterator; |
| 550 |
const_iterator begin() const { } |
| 551 |
iterator end() { return best_rrrrrrr_.end(); } |
| 552 |
iterator find(long ad_group_id) { return best_rrrrrrr_.find(ad_group_id); } |
| 553 |
const foo_12& GetMatch(const_iterator it) const {} |
| 554 |
void hmmmmh_27(long ad_group_id, const foo_12& addme); |
| 555 |
private: BestMap best_rrrrrrr_; |
| 556 |
vector<foo_12> rrrrrrr_buffer_; |
| 557 |
}; |
| 558 |
struct foo_10 : public dense_hash_set<blah_46> {}; |
| 559 |
class foo_9Set : public DensePtrSet<foo_9> {}; |
| 560 |
typedef map<blah_46, foo_7*> foo_6Data; |
| 561 |
typedef hash_map<long, linked_ptr<blah_57> > RejectedAdGroupMap; |
| 562 |
enum blah_43 {}; |
| 563 |
class foo_14 { |
| 564 |
public: foo_14(const unsigned int, const blah_16*, const int*); |
| 565 |
bool GathersMultipleRejectionReasons() const; |
| 566 |
void hmmmmh_30(blah_46 hahaha_id, blah_38 type); |
| 567 |
const foo_7* Insertfoo_6(const blah_46 hahaha_id, bool shengmo_0, bool shengmo_1, bool shengmo_2, bool shengmo_3, bool shengmo_4_rewrite, float multiplier, float context_score); |
| 568 |
void hmmmmh_7(blah_46 hahaha_id, blah_38 type); |
| 569 |
foo_9* Insertfoo_9(); |
| 570 |
bool hmmmmh_8(long ad_group_id, const foo_12 &entry); |
| 571 |
void hmmmmh_9(long ad_group_id); |
| 572 |
foo_13::iterator hmmmmh_0(long ad_group_id); |
| 573 |
bool hmmmmh_8(long ad_group_id, foo_13::iterator best, const foo_12& entry); |
| 574 |
void hmmmmh_5(const blah_46 hahaha_id); |
| 575 |
void hmmmmh_29(const blah_46 hahaha_id); |
| 576 |
bool hmmmmh_12(const blah_46 hahaha_id) const; |
| 577 |
bool hmmmmh_13(const blah_46 hahaha_id) const; |
| 578 |
const foo_9* Getfoo_9(const blah_46 hahaha_id) const; |
| 579 |
bool Gathersfoo_9() const {} |
| 580 |
const foo_10* rrrrrrr_type_data() const {} |
| 581 |
const foo_10* negative_rrrrrrr_type_data() const {} |
| 582 |
const foo_10* positive_rrrrrrr_type_data() const {} |
| 583 |
const foo_9Set* kw_info_set() const { } |
| 584 |
const foo_6Data* rewrite_data() const {} |
| 585 |
const vector<blah_17>& query_rectangles() const {} |
| 586 |
void hmmmmh_14(); |
| 587 |
void AddQueryRectangle(const blah_17& query_rectangle); |
| 588 |
void hmmmmh_15(long ad_group_id, const blah_46 hahaha_id, blah_33 reject_class, const char* reject_desc = __null); |
| 589 |
void hmmmmh_16(const vector<long>& rejected_sssr_ids); |
| 590 |
void Copy(const foo_14& cmi); |
| 591 |
void hmmmmh_10(); |
| 592 |
private: const blah_16* ad_request_; |
| 593 |
const int* cr_query_; |
| 594 |
blah_43 gather_flags_; |
| 595 |
vector<blah_17> query_rectangles_; |
| 596 |
foo_10 rrrrrrr_type_data_; |
| 597 |
foo_9Set kw_info_set_; |
| 598 |
foo_6Data rewrite_data_; |
| 599 |
scoped_ptr<RejectedAdGroupMap> rejected_sssr_map_; |
| 600 |
foo_13 ad_group_rrrrrrr_data_; |
| 601 |
vector<blah_46> geo_hahaha_; |
| 602 |
bool geo_hahaha_is_sorted_; |
| 603 |
foo_10 negative_rrrrrrr_type_data_, positive_rrrrrrr_type_data_; |
| 604 |
scoped_ptr<foo_10> extra_hahaha_set_; |
| 605 |
int dimension_id_; |
| 606 |
blah_31Set creative_formats_; |
| 607 |
scoped_ptr<dense_hash_set<unsigned long> > near_aaaaa_rrrrrrr_fps_; |
| 608 |
blah_41 comparison_policy_; |
| 609 |
blah_46 next_virtual_hahaha_id_; |
| 610 |
vector<void*>* sub_queries_; |
| 611 |
bool allow_only_whitelisted_customers_, automatic_hahaha_rrrrrrr_; |
| 612 |
scoped_ptr<blah_5> kw_arena_, expanded_rrrrrrr_arena_; |
| 613 |
}; |
| 614 |
class blah_19 { |
| 615 |
void hmmmmh_3(); |
| 616 |
enum blah_45 {}; |
| 617 |
}; |
| 618 |
void blah_19::hmmmmh_3() {} |
| 619 |
class blah_16 { |
| 620 |
public: int near_aaaaa_rrrrrrr_fps_size() const {} |
| 621 |
unsigned long near_aaaaa_rrrrrrr_fps(int i) const {} |
| 622 |
}; |
| 623 |
class blah_21 { |
| 624 |
protected: blah_21(char* first_block, const size_t block_size, bool align_to_page); |
| 625 |
void* GetMemoryFallback(const size_t size, const int align); |
| 626 |
void* GetMemory(const size_t size, const int align) { |
| 627 |
if ( size > 0 && size < remaining_ && align == 1 ) { |
| 628 |
last_alloc_ = freestart_; |
| 629 |
} |
| 630 |
return GetMemoryFallback(size, align); |
| 631 |
} |
| 632 |
char* freestart_; |
| 633 |
char* last_alloc_; |
| 634 |
size_t remaining_; |
| 635 |
}; |
| 636 |
class blah_5 : blah_21 { |
| 637 |
public: char* Alloc(const size_t size) { |
| 638 |
return reinterpret_cast<char*>(GetMemory(size, 1)); |
| 639 |
} |
| 640 |
}; |
| 641 |
class blah_25 { |
| 642 |
public: virtual ~blah_25(); |
| 643 |
}; |
| 644 |
class blah_17 : blah_25 { }; |
| 645 |
void Fillfoo_8(const foo_12& x2, struct foo_8* out) { |
| 646 |
out->packed_ctr1 = x2.qbb_score(); |
| 647 |
} |
| 648 |
const vector<blah_46> foo_12::hmmmmh_4; |
| 649 |
foo_14::foo_14(const unsigned int gather_flags, const blah_16* ad_request, const int* cr_query): ad_request_(ad_request), cr_query_(cr_query), gather_flags_(static_cast<blah_43>(gather_flags)), geo_hahaha_is_sorted_(false), dimension_id_(0), creative_formats_(kNumblah_31s), comparison_policy_(ACP_ECPM_EARLY), sub_queries_(new vector<void*>()), allow_only_whitelisted_customers_(false), automatic_hahaha_rrrrrrr_(false) { |
| 650 |
hmmmmh_10(); |
| 651 |
} |
| 652 |
void foo_14::hmmmmh_5(const blah_46 hahaha_id) { |
| 653 |
negative_rrrrrrr_type_data_.insert(hahaha_id); |
| 654 |
} |
| 655 |
void foo_14::hmmmmh_7(blah_46 hahaha_id, blah_38 type) { } |
| 656 |
foo_13::iterator foo_14::hmmmmh_0( long ad_group_id) { |
| 657 |
return ad_group_rrrrrrr_data_.find(ad_group_id); |
| 658 |
} |
| 659 |
bool foo_14::hmmmmh_8(long ad_group_id, foo_13::iterator best, const foo_12& entry) { |
| 660 |
rejected_sssr_map_->erase(ad_group_id); |
| 661 |
ad_group_rrrrrrr_data_.hmmmmh_27(ad_group_id, entry); |
| 662 |
} |
| 663 |
bool foo_14::hmmmmh_8(long ad_group_id, const foo_12& entry) { |
| 664 |
foo_13::iterator best = hmmmmh_0(ad_group_id); |
| 665 |
} |
| 666 |
void foo_14::hmmmmh_9(long ad_group_id) { |
| 667 |
ad_group_rrrrrrr_data_.erase(ad_group_id); |
| 668 |
} |
| 669 |
void foo_14::hmmmmh_10() { |
| 670 |
if (near_aaaaa_rrrrrrr_fps_ != __null) { |
| 671 |
blah_54(".cc", 226, WARNING).stream() << ""; |
| 672 |
for (int j = 0; |
| 673 |
j < ad_request_->near_aaaaa_rrrrrrr_fps_size(); j++) { |
| 674 |
near_aaaaa_rrrrrrr_fps_->insert(ad_request_->near_aaaaa_rrrrrrr_fps(j)); |
| 675 |
} |
| 676 |
} |
| 677 |
} |
| 678 |
const foo_7* foo_14::Insertfoo_6(const blah_46 hahaha_id, bool shengmo_0, bool shengmo_1, bool shengmo_2, bool shengmo_3, bool shengmo_4_rewrite, float multiplier, float context_score) { |
| 679 |
if (rrrrrrr_type_data_.count(hahaha_id) > 0) return __null; |
| 680 |
foo_7* new_info = new(expanded_rrrrrrr_arena_->Alloc(sizeof(foo_7))) foo_7(shengmo_0,shengmo_1, shengmo_2, shengmo_3, shengmo_4_rewrite, multiplier, context_score); |
| 681 |
pair<foo_6Data::iterator, bool> status = rewrite_data_.insert( make_pair(hahaha_id, new_info)); |
| 682 |
foo_7* inserted = status.first->second; |
| 683 |
if (!status.second) { |
| 684 |
if (inserted->CompareSameKeywordMatch(*new_info) < 0) *inserted = *new_info; |
| 685 |
} |
| 686 |
} |
| 687 |
foo_9* foo_14::Insertfoo_9() { |
| 688 |
foo_9* info = new(kw_arena_->Alloc(sizeof(foo_9))) foo_9; |
| 689 |
if (Gathersfoo_9()) kw_info_set_.insert(info); |
| 690 |
creative_formats_.Insert(CREATIVE_FORMAT_TEXT_NARROW); |
| 691 |
} |
| 692 |
bool foo_14::hmmmmh_12(const blah_46 hahaha_id) const { |
| 693 |
if (rrrrrrr_type_data_.count(hahaha_id)) return true; |
| 694 |
} |
| 695 |
bool foo_14::hmmmmh_13(const blah_46 hahaha_id) const { |
| 696 |
if (positive_rrrrrrr_type_data_.count(hahaha_id)) return true; |
| 697 |
} |
| 698 |
const foo_9* foo_14::Getfoo_9(const blah_46 hahaha_id) const { |
| 699 |
if (Gathersfoo_9()) return kw_info_set_.Find(hahaha_id.id()); |
| 700 |
static int occurrences_383 = 0, occurrences_mod_n_383 = 0; |
| 701 |
if (++occurrences_mod_n_383 > 1000) occurrences_mod_n_383 -= 1000; |
| 702 |
} |
| 703 |
void foo_14::hmmmmh_15(long ad_group_id, const blah_46 hahaha_id, blah_33 reject_class, const char* reject_desc) { |
| 704 |
if (rejected_sssr_map_ == __null) { |
| 705 |
blah_54("a.cc", 413, ERROR).stream() << "re NULL"; |
| 706 |
rejected_sssr_map_.reset(new RejectedAdGroupMap); |
| 707 |
} |
| 708 |
if (rejected_sssr_map_->count(ad_group_id) == 0) { |
| 709 |
blah_57* ad_rejection = new blah_57(); |
| 710 |
ad_rejection->set_collects_multiple_reasons( GathersMultipleRejectionReasons()); |
| 711 |
(*rejected_sssr_map_)[ad_group_id] = linked_ptr<blah_57>(ad_rejection); |
| 712 |
} |
| 713 |
blah_57& ad_rejection = *(*rejected_sssr_map_)[ad_group_id]; |
| 714 |
ad_rejection.AddReason(reject_class, reject_desc, hahaha_id, false); |
| 715 |
} |
| 716 |
void foo_14::hmmmmh_16(const vector<long>& rejected_sssr_ids) { |
| 717 |
for (vector<long>::const_iterator it = rejected_sssr_ids.begin(); |
| 718 |
it != rejected_sssr_ids.end(); ++it) { |
| 719 |
ad_group_rrrrrrr_data_.erase(*it); |
| 720 |
for (foo_13::const_iterator it = ad_group_rrrrrrr_data_.begin(); |
| 721 |
it != ad_group_rrrrrrr_data_.end(); ++it) { |
| 722 |
hmmmmh_15(it->first, ad_group_rrrrrrr_data_.GetMatch(it).hahaha_id(), BLACKLISTED); |
| 723 |
} |
| 724 |
} |
| 725 |
hmmmmh_30(blah_46::kBlacklistedID, ttttttt_9); |
| 726 |
} |
| 727 |
void foo_14::Copy(const foo_14& cmi) { |
| 728 |
rrrrrrr_type_data_ = *cmi.rrrrrrr_type_data(); |
| 729 |
negative_rrrrrrr_type_data_ = *cmi.negative_rrrrrrr_type_data(); |
| 730 |
positive_rrrrrrr_type_data_ = *cmi.positive_rrrrrrr_type_data(); |
| 731 |
if (cmi.Gathersfoo_9()) { |
| 732 |
kw_info_set_ = *cmi.kw_info_set(); |
| 733 |
rewrite_data_ = *cmi.rewrite_data(); |
| 734 |
} |
| 735 |
hmmmmh_14(); |
| 736 |
for (int i = 0; i < cmi.query_rectangles().size(); |
| 737 |
++i) AddQueryRectangle(cmi.query_rectangles()[i]); |
| 738 |
} |
| 739 |
void foo_13::hmmmmh_27(long ad_group_id, const foo_12& addme) { |
| 740 |
int& best_index = best_rrrrrrr_[ad_group_id]; |
| 741 |
rrrrrrr_buffer_.push_back(addme); |
| 742 |
} |
| 743 |
void foo_14::hmmmmh_29(const blah_46 hahaha_id) { |
| 744 |
if (extra_hahaha_set_ != __null) extra_hahaha_set_->erase(hahaha_id); |
| 745 |
} |