コード例 #1
0
ファイル: MappedMallocState.cpp プロジェクト: mheinsen/seec
void MallocState::print(llvm::raw_ostream &Out,
                        seec::util::IndentationGuide &Indentation) const
{
  std::string AddressString;
  
  {
    llvm::raw_string_ostream AddressStringStream(AddressString);
    seec::util::write_hex_padded(AddressStringStream, this->getAddress());
  }
  
  auto const LazyDescription =
    seec::LazyMessageByRef::create("SeeCClang",
                                   {"states", "MallocState"},
                                   std::make_pair("size",
                                                  int64_t(this->getSize())),
                                   std::make_pair("address",
                                                  AddressString.c_str()));
  
  UErrorCode ICUStatus = U_ZERO_ERROR;
  auto const Description = LazyDescription->get(ICUStatus, Locale());
  
  if (U_FAILURE(ICUStatus))
    return;
  
  Out << Indentation.getString() << Description << "\n";
  
  auto const Mapping = this->getAllocatorInstMapping();
  if (auto const Stmt = Mapping.getStmt()) {
    Indentation.indent();
    
    auto const &AST = Mapping.getAST()->getASTUnit();
    auto const &SrcManager = AST.getSourceManager();
    
    auto const LocStart = Stmt->getLocStart();
    auto const Filename = SrcManager.getFilename(LocStart);
    auto const Line = SrcManager.getSpellingLineNumber(LocStart);
    auto const Column = SrcManager.getSpellingColumnNumber(LocStart);
    
    auto const LazyLocation =
      seec::LazyMessageByRef::create("SeeCClang",
                                     {"states", "MallocStateAllocatedAt"},
                                     std::make_pair("filename",
                                                    Filename.str().c_str()),
                                     std::make_pair("line", int64_t(Line)),
                                     std::make_pair("column", int64_t(Column)));
    
    auto const Location = LazyLocation->get(ICUStatus, Locale());
    
    if (U_SUCCESS(ICUStatus))
      Out << Indentation.getString() << Location << "\n";
    
    Indentation.unindent();
  }
}
コード例 #2
0
ファイル: cursor.cpp プロジェクト: AndreasWelchlin/tntdb
    Row Cursor::fetch()
    {
      log_debug("sqlite3_step(" << stmt << ')');
      int ret = ::sqlite3_step(stmt);
      if (ret == SQLITE_DONE)
        return Row();
      else if (ret != SQLITE_ROW)
        throw Execerror("sqlite3_step", stmt, ret);

      return Row(new StmtRow(getStmt()));
    }
コード例 #3
0
ファイル: rules.c プロジェクト: gybjm2016/Compiler
void getCompSt(TypePoint returnType,TreeNode *head){
	TreeNode *child = head->firstChild->nextSibling;//child->name=DefList;
	syntaxTest(child);
	child = child->nextSibling;
	for(;;){
		if(child->name == Empty)
			break;
		child = child->firstChild;
		getStmt(returnType,child);
		child = child->nextSibling;
	}
}
コード例 #4
0
ファイル: rules.c プロジェクト: gybjm2016/Compiler
void getStmt(TypePoint returnType,TreeNode *head){
	TreeNode *child = head->firstChild;
	if(child->name == Exp){
		getExp(child);
	}
	else if(child->name == CompSt)
		getCompSt(returnType,child);
	else if(child->name == RETURN){
		TypePoint expType = getExp(child->nextSibling);
		if(testType(expType,returnType)==-1){
			printf("Error type 8 at Line %d: Type mismatched for return.\n",child->nextSibling->lineno);
			return;
		}
	}
	else if(child->name == WHILE){
		child = child->nextSibling->nextSibling;
		TypePoint p = getExp(child);
		if(!(p->kind==BASIC && p->data.basic==INT)){
			printf("Error type 7 at Line %d: Type mismatched for while condition.\n",child->lineno);
			return;
		}
		child = child->nextSibling->nextSibling;
		getStmt(returnType,child);
	}
	else{
		child = child->nextSibling->nextSibling;
		TypePoint p = getExp(child);
		if(!(p->kind == BASIC && p->data.basic == INT)){
			printf("Error type 7 at Line %d: Type mismatched for if condition.\n",child->lineno);
			return;
		}
		child = child->nextSibling->nextSibling;
		getStmt(returnType,child);
		child = child->nextSibling;
		if(child != NULL){
			getStmt(returnType,child->nextSibling);
		}
	}
}
コード例 #5
0
ファイル: cursor_iterator.cpp プロジェクト: 913862627/tntdb
    Cursor::const_iterator& Cursor::const_iterator::operator++()
    {
      // fetch next row
      log_debug("mysql_stmt_fetch");
      int ret = ::mysql_stmt_fetch(getStmt());

      if (ret == 1)
        throw Error("mysql_stmt_fetch", getDb());
      else if (ret == MYSQL_NO_DATA)
        cursor = Cursor();
#ifdef MYSQL_DATA_TRUNCATED
      else if (ret == MYSQL_DATA_TRUNCATED)
      {
        log_error("mysql_stmt_fetch returned MYSQL_DATA_TRUNCATED");
        throw std::runtime_error("mysql_stmt_fetch returned MYSQL_DATA_TRUNCATED");
      }
#endif
    }
コード例 #6
0
llvm::Value* minipascal::NLoop::codeGen(CodeGenContext* context)
{
        char buf[32];
        int count = sprintf(buf, "LOOP_CHECK_%d", index);
        llvm::BasicBlock* check_bb = llvm::BasicBlock::Create(llvm::getGlobalContext(), buf, context->getCurBlock()->getBlock()->getParent(), 0);
        count = sprintf(buf, "LOOP_%d", index);
        llvm::BasicBlock* body_bb = llvm::BasicBlock::Create(llvm::getGlobalContext(), buf, context->getCurBlock()->getBlock()->getParent(), 0);
        count = sprintf(buf, "LOOP_CONT_%d", index);
        llvm::BasicBlock* loop_cont = llvm::BasicBlock::Create(llvm::getGlobalContext(), buf, context->getCurBlock()->getBlock()->getParent(), 0);
        
        // create jump instruction which is used to jump to loop check
        context->builder->CreateBr(check_bb);
        context->builder->SetInsertPoint(check_bb);
        
        llvm::Value* condvalue = getCond()->codeGen(context);
        if(condvalue == NULL) return NULL;
        
        // condition type check
        BooleanType temp;
        if(!(getCond()->getType()->compare(&temp)))
        {
                IntType inttest;
                if(!(getCond()->getType()->compare(&inttest)))
                {
                        showError("Condition are not boolean or integer type");
                        setFail(true);
                        context->fail = true;
                        return NULL;
                }
                condvalue = context->builder->CreateICmpNE(condvalue, llvm::ConstantInt::get(inttest.getLLVMType(), 0, true), "");
        }
        
        context->builder->CreateCondBr(condvalue, body_bb, loop_cont);
        
        context->builder->SetInsertPoint(body_bb);
        llvm::Value* bodyvalue = getStmt()->codeGen(context);
        context->builder->CreateBr(check_bb);
        
        context->builder->SetInsertPoint(loop_cont);
        
        ++index;
        return condvalue;
}
コード例 #7
0
 clang::Expr* getExpr() {
   assert(llvm::isa<clang::Expr>(getStmt()) && "Must be an expression.");
   return llvm::cast<clang::Expr>(getStmt());
 }
コード例 #8
0
 const clang::Stmt* getStmt() const { return getStmt(); }