2014-01-07 14:57:02 +04:00
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
2015-01-12 11:22:39 +03:00
// RUN: cat %s | %cling -fno-rtti | FileCheck %s
2013-04-24 17:12:08 +04:00
// This test makes sure the interpreter doesn't create many useless empty
// transactions.
// Author: Vassil Vassilev
# include "cling/Interpreter/Interpreter.h"
# include "cling/Interpreter/Transaction.h"
2013-04-24 19:01:35 +04:00
# include "clang/AST/Decl.h"
2013-04-24 17:12:08 +04:00
# include <stdio.h>
. rawInput 1
2013-06-10 14:41:58 +04:00
using namespace cling ;
2013-04-24 17:12:08 +04:00
void generateNestedTransaction ( int depth ) {
if ( ! depth )
return ;
cling : : Interpreter : : PushTransactionRAII RAIIT ( gCling ) ;
if ( depth | 0x1 ) { // if odd
char buff [ 100 ] ;
sprintf ( buff , " int i%d; " , depth ) ;
gCling - > process ( buff ) ;
} // this will cause every even transaction to be reused.
2014-08-04 06:05:42 +04:00
generateNestedTransaction ( - - depth ) ;
2013-04-24 17:12:08 +04:00
}
. rawInput 0
generateNestedTransaction ( 5 ) ;
const cling : : Transaction * T = gCling - > getFirstTransaction ( ) ;
while ( T ) {
2013-11-19 14:45:01 +04:00
if ( T - > empty ( ) )
2013-04-24 17:12:08 +04:00
printf ( " Empty transaction detected! \n " ) ;
2013-06-11 14:35:54 +04:00
else if ( T - > getWrapperFD ( ) & & T - > getWrapperFD ( ) - > getKind ( ) ! = clang : : Decl : : Function )
2013-04-24 19:01:35 +04:00
printf ( " Unexpected wrapper kind! \n " ) ;
2013-06-10 14:41:58 +04:00
if ( T - > getState ( ) ! = Transaction : : kCommitted )
2013-04-24 19:01:35 +04:00
printf ( " Unexpected transaction state! \n " ) ;
2013-04-24 17:12:08 +04:00
//T->printStructure();
T = T - > getNext ( ) ;
}
printf ( " Just make FileCheck(CHECK-NOT) happy. \n " )
//CHECK-NOT:Empty transaction detected!
2013-04-24 19:01:35 +04:00
//CHECK-NOT:Unexpected wrapper kind!
//CHECK-NOT:Unexpected transaction state!
2013-04-24 17:12:08 +04:00
. q