void doLoop() {
    for (iterator I = begin(), E = end(); I != E; ++I)
      (void) *I;
    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
    // CHECK-FIXES: for (auto & Elem : *this)

    for (iterator I = C::begin(), E = C::end(); I != E; ++I)
      (void) *I;
    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
    // CHECK-FIXES: for (auto & Elem : *this)

    for (iterator I = begin(), E = end(); I != E; ++I) {
      (void) *I;
      doSomething();
    }

    for (iterator I = begin(); I != end(); ++I)
      (void) *I;
    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
    // CHECK-FIXES: for (auto & Elem : *this)

    for (iterator I = begin(); I != end(); ++I) {
      (void) *I;
      doSomething();
    }
  }
Beispiel #2
0
void Player_Test::randomPlayer(){
    Player* player = new FirstPlayer();

    QTcpSocket* tcpSocket = new QTcpSocket();
    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(doSomething()));

    tcpSocket->connectToHost(QHostAddress::LocalHost, 9147);

    QString message = QString("(info)");

    tcpSocket->write("POST / HTTP/1.1\r\n");
    //tcpSocket->write("Host: 127.0.0.1:9147\r\n");
    tcpSocket->write("Connection: keep-alive\r\n");
    tcpSocket->write(tr("Content-Length: %1\r\n").arg(message.length()).toUtf8());
    tcpSocket->write("Origin: http://ggp.stanford.edu\r\n");
    tcpSocket->write("Content-type: application/x-www-form-urlencoded\r\n");
    tcpSocket->write("Accept: */*\r\n");
    tcpSocket->write("\r\n");
    tcpSocket->write(message.toUtf8());


    QTimer* timer1 = new QTimer();
    timer1->singleShot(2000, this, SLOT(doSomething()));
    connect(timer1, SIGNAL(timeout()), timer1, SLOT(deleteLater()));

//    std::chrono::milliseconds duration(2000);
//    std::this_thread::sleep_for(duration);

    delete player;
}
Beispiel #3
0
int main(int argc, char** argv) {

	cba_print_code();

	// for now this is simply testing the primitives
	cba_dump_thread_regions();
	cba_dump_execution_net();
	cba_dump_state_graph();

	cba_dump_equations();

	#pragma omp parallel
	{
		#pragma omp single
		{
			int x = 1;
		}
	}

	// also test some cilk stuff ..
	spawn doSomething();
	spawn doSomething();
	sync;
	
	return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
	B bObj1;
	doSomething(bObj1);

	B bObj2(28);
	doSomething(28);	//error 매개변수가 Btype이 아니기 때문
	doSomething(B(28));
	return 0;
}
Beispiel #5
0
void qHashBench() {
    QElapsedTimer timer;
    timer.start();
    QHash<int,triple> data;
    triple point;
    int i;

    for (i = 0; i < RAND_COUNT; ++i) {
        point.x = i;
        point.y = rand();
        point.z = rand();
        //printf("%d %d %d %d\n", i, point.x, point.y, point.z);
        data[i] = point;
    }
    qDebug() << Q_FUNC_INFO << "creation: elapsed" << timer.elapsed();
    timer.restart();
    foreach (const triple &t, data) {
        if (t.x % 1000 == 0)
            doSomething(t.x);
    }
    qDebug() << "   foreach: elapsed" << timer.elapsed();
#if QT_VERSION >= 0x050700
    timer.restart();
    foreach (const triple &t, qAsConst(data)) {
        if (t.x % 1000 == 0)
            doSomething(t.x);
    }
    qDebug() << "   qAsConst foreach: elapsed" << timer.elapsed();
#endif
    timer.restart();
    for( auto it = data.begin(); it != data.end(); ++it ) {
        if (it->x % 1000 == 0)
            doSomething(it->x);
    }
    qDebug() << "   range-based for: elapsed" << timer.elapsed();
#if QT_VERSION >= 0x050700
    timer.restart();
    for( auto it = qAsConst(data).begin(); it != qAsConst(data).end(); ++it ) {
        if (it->x % 1000 == 0)
            doSomething(it->x);
    }
    qDebug() << "   qAsConst range-based for: elapsed" << timer.elapsed();
#endif
    timer.restart();
    for (i = 0; i < RAND_COUNT; ++i) {
        auto it = data.find(i);
        Q_ASSERT(it.value().x == i);
        if (it->x % 1000 == 0)
            doSomething(it.value().x);
    }
    qDebug() << "   find: elapsed" << timer.elapsed();
}
int main(int argc, char *argv[])
{
	char *str = (char *)NULL;
	if ((str = (char *)malloc(256*sizeof(char))) != NULL)
	{
		strcpy(str, "Falut!");
		doSomething(str);
		printf("%s\n", str);
		free(str);	
				
		doSomething(str);							/* FLAW */
	}
	return 0;
}
Beispiel #7
0
int main() {
    doSomething();

    puts("I don't think you did anything different :C");

    return 0;
}
int main() {
	int x = 5;
	int y = 5;
    int z = doSomething(&x,&y,(int (*)(int *,int *)) (add));
    printf( "%d\n", z );
    return 0;
}
int main()
{
	try {
		doSomething();
	} catch (const MyException& e) {
		std::cout << __func__ << " caught MyException: " << e.what() << std::endl;
/*
		const std::nested_exception* pNested =
			dynamic_cast<const std::nested_exception*>(&e);
		if (pNested) {
			try {
				pNested->rethrow_nested();
			} catch (const std::runtime_error& e) {
				// Handle nested exception
				std::cout << "  Nested exception: " << e.what() << std::endl;
			}
		}
*/
		try {
			std::rethrow_if_nested(e);
		} catch (const std::runtime_error& e) {
			// Handle nested exception
			std::cout << "  Nested exception: " << e.what() << std::endl;
		}
	}

	return 0;
}
Beispiel #10
0
main (int argc, char** argv) {
     int a=10;
     int b=20;
     int r;

     r=plus(a,b);
     printf("plus %d+%d=%d\n", a, b, r);
     a=b=100;
     bplus(a,b,&r);
     printf("bplus %d+%d=%d\n", a, b, r);
     printf("\n==== appel indirect\n");
     printf("? %d ? %d=%d\n", a, b, doSomething(plus,a,b));
     printf("? %d ? %d=%d\n", a, b, doSomething(mult,a,b));


}
Beispiel #11
0
FirstStartWizard::FirstStartWizard(QWidget *parent) :QWizard(parent)
{
	ui.setupUi(this);
	ui.lineEdit_import->setText(QDir::homePath() + "/.kde/share/apps/amarok/collection.db");
	ui.lineEdit_collect->setText(QDir::homePath());
	connect(this, SIGNAL(accepted()), this, SLOT(doSomething()));
}
Beispiel #12
0
int test_nullptr5()
{
	int* a = NULL; // ok
	//int* b = (void*)0; // error C2440: “初始化”: 无法从“void *”转换为“int *”
	int* c = 0; // ok

	// the argument is definitely a null pointer (not an integer)
	doSomething(nullptr); // You passed in a null pointer
	doSomething(0); // You passed in a null pointer
	doSomething(NULL); // You passed in a null pointer

	// call doSomething_ with an argument of type std::nullptr_t
	doSomething_(nullptr); // in doSomething_()

	return 0;
}
// Long parameters in method definition
void method50(int                                                   int_param,
              SomeLongNamespace::OtherLongNamespace::SomeLongType   long_parameter_name,
              float                                                 float_param,
              double                                                double_param,
              const string &                                        string_param)
{
	doSomething();
}
Beispiel #14
0
	void operator()()
	{
		for (unsigned j = 0; j<100; ++j)
		{
			doSomething(j); //this is potential danger.(dangling pointer)
		}

		std::cout << "thread finished !" << std::endl;
	}
Beispiel #15
0
void testSubclassSmartPointer() {
  char *mem = (char*)malloc(4);
  {
    Subclass Deleter(mem);
    // Remove dead bindings...
    doSomething();
    // destructor called here
  }
  *mem = 0; // expected-warning{{Use of memory after it is freed}}
}
Beispiel #16
0
int main()
{
  threadSafeLazyInitializationWithMutex();

  undefinedBehavirourWithDoubleCheckedLocking(); /* (!) Oops */

  doSomething();

  return 0;
}
Beispiel #17
0
void testMultipleInheritance2() {
  char *mem = (char*)malloc(4);
  {
    MultipleInheritance Deleter(0, mem);
    // Remove dead bindings...
    doSomething();
    // destructor called here
  }
  *mem = 0; // expected-warning{{Use of memory after it is freed}}
}
Beispiel #18
0
void testMultipleInheritance3() {
  char *mem = (char*)malloc(4);
  {
    MultipleInheritance Deleter(mem, mem);
    // Remove dead bindings...
    doSomething();
    // destructor called here
    // expected-warning@27 {{Attempt to free released memory}}
  }
}
void increasing_length(
	int                int_param,
	float              float_param,
	double             double_param,
	ah_long_t &        string_param,
	very_long_type     t_param,
	even_longer_type   l_param)
{
	doSomething();
}
Beispiel #20
0
void
foo (void)
{
  int i;
  for (i = 0;
       array[i]  /* { dg-message "note: possible undefined statement is here" } */
       && i < 5; /* { dg-warning "loop exit may only be reached after undefined behavior" } */
       i++)
    doSomething(array[i]);
}
Beispiel #21
0
void UseUninitializedVariable()
{
    for (int i = 0; i < 2; i++)
    {
        int k = 0;
        if (!(i & 1))
            k = i;

        if (i % 2)
            doSomething((short)k);            
    }
}
Beispiel #22
0
int main(int argc, char **argv)
{
	debug("file: %s", __FILE__);
	debug("line: %d", __LINE__);
	log_info("date compiled: %s", __DATE__);
	log_info("time compiled: %s", __TIME__);
	log_error("something is not right in: %s", __func__);

	doSomething(0);

	return 0;
}
Beispiel #23
0
 void doLoop() {
   for (iterator I = begin(), E = end(); I != E; ++I) {
     // CHECK: for (auto & elem : *this) {
   }
   for (iterator I = C::begin(), E = C::end(); I != E; ++I) {
     // CHECK: for (auto & elem : *this) {
   }
   for (iterator I = begin(), E = end(); I != E; ++I) {
     // CHECK: for (iterator I = begin(), E = end(); I != E; ++I) {
     // RISKY: for (auto & elem : *this) {
     doSomething();
   }
   for (iterator I = begin(); I != end(); ++I) {
     // CHECK: for (auto & elem : *this) {
   }
   for (iterator I = begin(); I != end(); ++I) {
     // CHECK: for (iterator I = begin(); I != end(); ++I) {
     // RISKY: for (auto & elem : *this) {
     doSomething();
   }
 }
Beispiel #24
0
void doThings()
{
  //ErrorObject *err; //CEXCEPTION_T err is same

//  Try
//  {
    doSomething();
  // } Catch(err)
  // {
    // printf("Error: %s\n", err->errorMsg);
    // freeError(err);
  // }
}
voidVoid testFunction() {
    int i = random();
    __block voidVoid inner = ^{ doSomething(i); };
    //printf("inner, on stack, is %p\n", (void*)inner);
    /*__block*/ voidVoid outer = ^{
        //printf("will call inner block %p\n", (void *)inner);
        inner();
    };
    //printf("outer looks like: %s\n", _Block_dump(outer));
    voidVoid result = Block_copy(outer);
    //Block_release(inner);
    return result;
}
Beispiel #26
0
void CoolScaleObject::Run (float ) {
	auto pos = m_target->getPosition();
	if (pos != m_previousPosition) {
		auto iterx = m_xGrid.upper_bound (pos.x);
		auto itery = m_yGrid.upper_bound (pos.y);
		int ix = ((iterx == m_xGrid.end()) ? (m_cols-1) : (std::max(iterx->second-1, 0)));
		int iy = ((itery == m_yGrid.end()) ? (m_rows-1) : (std::max(itery->second-1, 0)));
		int index = iy*m_cols + ix;
		glm::vec3 coeff = m_coefficients[index];
		float value = coeff.x * pos.x + coeff.y * pos.y + coeff.z;
		doSomething (value);
		m_previousPosition = pos;
	}
}
Beispiel #27
0
void unorderedMapBench() {
    QElapsedTimer timer;
    timer.start();
    std::unordered_map<int,triple> data;
    triple point;
    int i;

    for (i = 0; i < RAND_COUNT; ++i) {
        point.x = i;
        point.y = rand();
        point.z = rand();
        //printf("%d %d %d %d\n", i, point.x, point.y, point.z);
        data[i] = point;
    }
    qDebug() << Q_FUNC_INFO << "creation: elapsed" << timer.elapsed();
    timer.restart();
    foreach (auto t, data) {
        if (t.second.x % 1000 == 0)
            doSomething(t.second.x);
    }
    qDebug() << "   foreach: elapsed" << timer.elapsed();
    timer.restart();
    for( auto it = data.begin(); it != data.end(); ++it ) {
        if (it->second.x % 1000 == 0)
            doSomething(it->second.x);
    }
    qDebug() << "   range-based for: elapsed" << timer.elapsed();

    timer.restart();
    for (i = 0; i < RAND_COUNT; ++i) {
        auto it = data.find(i);
        Q_ASSERT(it->second.x == i);
        if (it->second.x % 1000 == 0)
            doSomething(it->first);
    }
    qDebug() << "   find: elapsed" << timer.elapsed();
}
Beispiel #28
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QPushButton btn("Click ME !");
    Clicker clicker;

    QObject::connect(
                &btn, SIGNAL(clicked()),
                &clicker, SLOT(doSomething()));
    btn.show();

    app.exec();
    return 0;
}
  void doLoop() const {
    for (const_iterator I = begin(), E = end(); I != E; ++I) {
    }
    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
    // CHECK-FIXES: for (auto & elem : *this) {

    for (const_iterator I = C::begin(), E = C::end(); I != E; ++I) {
    }
    // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
    // CHECK-FIXES: for (auto & elem : *this) {

    for (const_iterator I = begin(), E = end(); I != E; ++I) {
      doSomething();
    }
  }
Beispiel #30
0
int main() {
	int n;
	Stack *stack;
	Key *item;
	item = (Key*) malloc (sizeof(Key));

	int i, j;
	

	printf("Enter the size of square:\n");
	while((n = getInt()) < 2) {
		printf("Please enter an integer which is greater than 1\n");
	}

	stack = makeStack();
	initialize(stack);

	for(i = 0; i < n; i++) {
		for(j = 0; j < n; j++) {
			item->square[i][j] = 0;
		}
	}

	push(&stack, item);

	doSomething(&stack, n);




	//printSquareContent(pop(&stack), n);



	// for(i = 0; i < 5; i++) {
	// 	a->a = i;
	// 	push(&stack, a);	
	// }

	// printf("\n");
	// while(!isEmpty(stack)) {
	// 	printf("%d\n", pop(&stack)->a);
	// }

	free(item);
	free(stack);
	return 0;
}