//------------------------------------------------------------------------------ // CLING - the C++ LLVM-based InterpreterG :) // author: Vassil Vassilev // // 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. //------------------------------------------------------------------------------ #include "CheckEmptyTransactionTransformer.h" #include "TransactionUnloader.h" #include "cling/Utils/AST.h" #include "clang/AST/Decl.h" #include "clang/AST/Stmt.h" using namespace clang; namespace cling { ASTTransformer::Result CheckEmptyTransactionTransformer::Transform(Decl* D) { FunctionDecl* FD = cast(D); assert(utils::Analyze::IsWrapper(FD) && "Expected wrapper"); CompoundStmt* CS = cast(FD->getBody()); if (!CS->size() || (CS->size() == 1 && isa(CS->body_back()))) { // This is an empty wrapper function. Get rid of it. // We know that it didn't end up in the EE by design. TransactionUnloader U(m_Sema, /*CodeGenerator*/0); U.UnloadDecl(FD); return Result(0, true); } return Result(D, true); } } // end namespace cling