void testArgumentConstructorWithDestructor() { AddressVector<ClassWithDestructor> v; consume(make3(v)); #if ELIDE // 0. Construct the argument. // 1. Forced push() in consume(). // 2. Destroy the argument. clang_analyzer_eval(v.len == 3); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] == v.buf[1]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[1] == v.buf[2]); // expected-warning{{TRUE}} #else // 0. Construct the temporary in make1(). // 1. Construct the temporary in make2(). // 2. Destroy the temporary in make1(). // 3. Construct the temporary in make3(). // 4. Destroy the temporary in make2(). // 5. Construct the temporary here. // 6. Destroy the temporary in make3(). // 7. Construct the argument. // 8. Forced push() in consume(). // 9. Destroy the argument. Notice the reverse order! // 10. Destroy the temporary here. clang_analyzer_eval(v.len == 11); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] == v.buf[2]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[1] == v.buf[4]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[3] == v.buf[6]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[5] == v.buf[10]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[7] == v.buf[8]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[8] == v.buf[9]); // expected-warning{{TRUE}} #endif }
obj make_dequeue( void ) { return make3( dequeue_class, make_gvec( vector_class, SLOT(5), FALSE_OBJ ), ZERO, ZERO ); }
static obj mpz_to_bignum( mpz_t n ) { return make3( bignum_class, int2fx( n[0]._mp_alloc ), int2fx( n[0]._mp_size ), DATAPTR_TO_PTR( n[0]._mp_d ) ); }
obj flush_link_data( void ) { obj e, v = alloc( SLOT(num_link_data_entries), vector_class ); struct unit_linkage_data *p; unsigned i; for (i=num_link_data_entries, p=link_top; p; p=p->next) { char t1[30], t2[30]; i--; sprintf( t1, "memory:%lu", (unsigned long)p->link_meta_data ); sprintf( t2, "memory:%lu", (unsigned long)p->link_unit_data ); e = make3( vector_class, make_string( p->name ), make_string( t1 ), make_string( t2 ) ); gvec_write_init_ptr( v, SLOT(i), e ); } link_top = NULL; num_link_data_entries = 0; return v; }
void testMultipleReturns() { AddressVector<ClassWithoutDestructor> v; ClassWithoutDestructor c = make3(v); #if ELIDE clang_analyzer_eval(v.len == 1); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] == &c); // expected-warning{{TRUE}} #else clang_analyzer_eval(v.len == 5); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] != v.buf[1]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[1] != v.buf[2]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[2] != v.buf[3]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[3] != v.buf[4]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[4] == &c); // expected-warning{{TRUE}} #endif }
static SkImageFilter* make7() { SkImageFilter* outer = SkOffsetImageFilter::Create(SkIntToScalar(16), SkIntToScalar(16)); SkImageFilter* inner = make3(); SkAutoUnref aur0(outer); SkAutoUnref aur1(inner); SkImageFilter* compose = SkComposeImageFilter::Create(outer, inner); SkAutoUnref aur2(compose); SkColorFilter* cf = SkColorFilter::CreateModeFilter(0x880000FF, SkXfermode::kSrcIn_Mode); SkAutoUnref aur3(cf); SkImageFilter* blue = SkColorFilterImageFilter::Create(cf); SkAutoUnref aur4(blue); return SkMergeImageFilter::Create(compose, blue); }
void testArgumentConstructorWithoutDestructor() { AddressVector<ClassWithoutDestructor> v; consume(make3(v)); #if ELIDE clang_analyzer_eval(v.len == 2); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] == v.buf[1]); // expected-warning{{TRUE}} #else clang_analyzer_eval(v.len == 6); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] != v.buf[1]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[1] != v.buf[2]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[2] != v.buf[3]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[3] != v.buf[4]); // expected-warning{{TRUE}} // We forced a push() in consume(), let's see if the address here matches // the address during construction. clang_analyzer_eval(v.buf[4] == v.buf[5]); // expected-warning{{TRUE}} #endif }
static obj get_bytecode_correlation( void ) { obj q = make_dequeue(); int prev, op; for (prev=0; prev<512; prev++) for (op=0; op<512; op++) { int n = bci_corr[prev][op]; if (n != 0) { obj entry = make3( vector_class, int2fx(n), int2fx(prev), int2fx(op) ); dequeue_push_back( q, entry ); } } return dequeue_state(q); }
void testMultipleReturnsWithDestructors() { AddressVector<ClassWithDestructor> v; { ClassWithDestructor c = make3(v); // Check if the last destructor is an automatic destructor. // A temporary destructor would have fired by now. #if ELIDE clang_analyzer_eval(v.len == 1); // expected-warning{{TRUE}} #else clang_analyzer_eval(v.len == 9); // expected-warning{{TRUE}} #endif } #if ELIDE // 0. Construct the variable. Yes, constructor in make1() constructs // the variable 'c'. // 1. Destroy the variable. clang_analyzer_eval(v.len == 2); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] == v.buf[1]); // expected-warning{{TRUE}} #else // 0. Construct the temporary in make1(). // 1. Construct the temporary in make2(). // 2. Destroy the temporary in make1(). // 3. Construct the temporary in make3(). // 4. Destroy the temporary in make2(). // 5. Construct the temporary here. // 6. Destroy the temporary in make3(). // 7. Construct the variable. // 8. Destroy the temporary here. // 9. Destroy the variable. clang_analyzer_eval(v.len == 10); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[0] == v.buf[2]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[1] == v.buf[4]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[3] == v.buf[6]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[5] == v.buf[8]); // expected-warning{{TRUE}} clang_analyzer_eval(v.buf[7] == v.buf[9]); // expected-warning{{TRUE}} #endif }
obj rs_gf_find_method( obj gf, obj rcvr ) { obj c, m, impl, h, k; UINT_32 k_ix, v_ix; #ifdef GF_DEBUG if (!foo) foo = fopen( "/tmp/gf.trc", "w" ); #endif /* GF_DEBUG */ c = object_class(rcvr); h = FX_AND(gvec_ref(c, CLASS_HASH_CODE),int2fx(3*2)); k_ix = GF_CACHE_0_K + FXWORDS_TO_RIBYTES(h); v_ix = k_ix + SLOT(1); k = gvec_ref( gf, k_ix ); #ifdef GF_DEBUG gf_stat(gf); #endif /* GF_DEBUG */ if (EQ(k,c)) return gvec_ref( gf, v_ix ); else { /* check the victim entry */ k = gvec_ref( gf, GF_VICTIM_K ); if (EQ(k,c)) { m = gvec_ref( gf, GF_VICTIM_V ); /* a hit -- victimize the primary entry * (note: there is no way you can hit in the victim cache * if your primary entry is #f) */ gvec_write_ptr( gf, GF_VICTIM_K, gvec_ref( gf, k_ix ) ); gvec_write_ptr( gf, GF_VICTIM_V, gvec_ref( gf, v_ix ) ); gvec_write_ptr( gf, k_ix, k ); gvec_write_ptr( gf, v_ix, m ); return m; } else { obj ov, new_ov, prev = ZERO; #ifdef GF_DEBUG fprintf( foo, "%s: check overflow for key = %s\n", symbol_text( gvec_ref( gf, SLOT(3) ) ), symbol_text( class_name( c ) ) ); if (truish( gvec_ref( gf, k_ix ) )) fprintf( foo, " primary[%d] => %s\n", fx2int(h), symbol_text( class_name( gvec_ref( gf, k_ix ) ) ) ); if (truish(k)) fprintf( foo, " victim => %s\n", symbol_text( class_name( k ) ) ); #endif /* GF_DEBUG */ /* a primary miss -- check the overflow list */ for (ov = gvec_ref( gf, GF_CACHE_OVERFLOW ); !EQ(ov,FALSE_OBJ); ov = gvec_ref( ov, SLOT(0) ) ) { k = gvec_ref( ov, SLOT(1) ); #ifdef GF_DEBUG fprintf( foo, " overflow {%#x} => %s\n", ov, symbol_text( class_name( k ) ) ); #endif /* GF_DEBUG */ if (EQ(k,c)) { #ifdef GF_DEBUG fprintf( foo, " HIT (prev = {%#x})\n", prev ); #endif /* GF_DEBUG */ m = gvec_ref( ov, SLOT(2) ); /* found it in the overflow list... move this entry * to the primary cache area and spill the victim cache */ new_ov = make3( vector_class, (EQ(prev,ZERO) ? gvec_ref( ov, SLOT(0) ) : gvec_ref( gf, GF_CACHE_OVERFLOW )), gvec_ref( gf, GF_VICTIM_K ), gvec_ref( gf, GF_VICTIM_V ) ); gvec_write_ptr( gf, GF_VICTIM_K, gvec_ref( gf, k_ix ) ); gvec_write_ptr( gf, GF_VICTIM_V, gvec_ref( gf, v_ix ) ); if (!EQ(prev,ZERO)) gvec_write( prev, SLOT(0), gvec_ref( ov, SLOT(0) ) ); gvec_write_ptr( gf, GF_CACHE_OVERFLOW, new_ov ); gvec_write_ptr( gf, k_ix, k ); gvec_write_ptr( gf, v_ix, m ); #ifdef GF_DEBUG gf_stat(gf); #endif /* GF_DEBUG */ return m; } prev = ov; } #ifdef GF_DEBUG fprintf( foo, " MISS\n" ); #endif /* GF_DEBUG */ return FALSE_OBJ; } } }