当前位置: 首页>>代码示例>>C++>>正文


C++ Stmt类代码示例

本文整理汇总了C++中Stmt的典型用法代码示例。如果您正苦于以下问题:C++ Stmt类的具体用法?C++ Stmt怎么用?C++ Stmt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Stmt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindSemiAfterLocation

void FakeDirectiveHandler::InsertAccess(Expr * Current,
                                    DeclRefExpr * Original,
                                    bool Write,
                                    vector<LocalStmtPair> WritePairs,
                                    bool ActualVar,
                                    string Struct) {

  if (!ActualVar) return;
  
  const Type * T = Current->getType().getTypePtr();
  
  if (FullDirectives->IsPrivate(Original, Struct, T, Original->getLocStart())) {
    return;
  }

  vector<LocalStmtPair>::iterator it;

  CompilerInstance &CI = FullDirectives->GetCI(Current->getLocStart());

  for (it = WritePairs.begin(); it != WritePairs.end(); it++) {
  
    bool insertAfter = it->insertAfter;
    Stmt * curStmt = it->stmt;

    bool isBracket = false;

    SourceLocation start = curStmt->getLocStart();
    SourceLocation end = FindSemiAfterLocation(curStmt->getLocEnd(),
                                               CI.getASTContext());

    if (end.isInvalid()) {
      end = curStmt->getLocEnd();
      isBracket = true;
    }
    
    SourceLocation loc;
    
    if (insertAfter) {
      if (isBracket) {
        loc = end;
      } else {
        loc = end.getLocWithOffset(1);
      }
    } else {
      loc = start;
    }
    
    loc = tools::UnpackMacroLoc(loc, CI);

    if (GetOrSetAccessed(loc, Current, Write)) {
      continue;
    }

    FullDirectives->InsertDeclAccess(Original->getFoundDecl(), Write);

  }

}
开发者ID:divot,项目名称:SpecCodeConv,代码行数:58,代码来源:FakeDirectiveHandler.cpp

示例2: while

/// VerifyJumps - Verify each element of the Jumps array to see if they are
/// valid, emitting diagnostics if not.
void JumpScopeChecker::VerifyJumps() {
  while (!Jumps.empty()) {
    Stmt *Jump = Jumps.pop_back_val();

    // With a goto,
    if (GotoStmt *GS = dyn_cast<GotoStmt>(Jump)) {
      CheckJump(GS, GS->getLabel(), GS->getGotoLoc(),
                diag::err_goto_into_protected_scope);
      continue;
    }

    if (SwitchStmt *SS = dyn_cast<SwitchStmt>(Jump)) {
      for (SwitchCase *SC = SS->getSwitchCaseList(); SC;
           SC = SC->getNextSwitchCase()) {
        assert(LabelAndGotoScopes.count(SC) && "Case not visited?");
        CheckJump(SS, SC, SC->getLocStart(),
                  diag::err_switch_into_protected_scope);
      }
      continue;
    }

    unsigned DiagnosticScope;

    // We don't know where an indirect goto goes, require that it be at the
    // top level of scoping.
    if (IndirectGotoStmt *IG = dyn_cast<IndirectGotoStmt>(Jump)) {
      assert(LabelAndGotoScopes.count(Jump) &&
             "Jump didn't get added to scopes?");
      unsigned GotoScope = LabelAndGotoScopes[IG];
      if (GotoScope == 0) continue;  // indirect jump is ok.
      S.Diag(IG->getGotoLoc(), diag::err_indirect_goto_in_protected_scope);
      DiagnosticScope = GotoScope;
    } else {
      // We model &&Label as a jump for purposes of scope tracking.  We actually
      // don't care *where* the address of label is, but we require the *label
      // itself* to be in scope 0.  If it is nested inside of a VLA scope, then
      // it is possible for an indirect goto to illegally enter the VLA scope by
      // indirectly jumping to the label.
      assert(isa<AddrLabelExpr>(Jump) && "Unknown jump type");
      LabelStmt *TheLabel = cast<AddrLabelExpr>(Jump)->getLabel();

      assert(LabelAndGotoScopes.count(TheLabel) &&
             "Referenced label didn't get added to scopes?");
      unsigned LabelScope = LabelAndGotoScopes[TheLabel];
      if (LabelScope == 0) continue; // Addr of label is ok.

      S.Diag(Jump->getLocStart(), diag::err_addr_of_label_in_protected_scope);
      DiagnosticScope = LabelScope;
    }

    // Report all the things that would be skipped over by this &&label or
    // indirect goto.
    while (DiagnosticScope != 0) {
      S.Diag(Scopes[DiagnosticScope].Loc, Scopes[DiagnosticScope].Diag);
      DiagnosticScope = Scopes[DiagnosticScope].ParentScope;
    }
  }
}
开发者ID:Gcrosby5269,项目名称:clamav-bytecode-compiler,代码行数:60,代码来源:JumpDiagnostics.cpp

示例3: mutate

Stmt IRMutator2::visit(const LetStmt *op) {
    Expr value = mutate(op->value);
    Stmt body = mutate(op->body);
    if (value.same_as(op->value) &&
        body.same_as(op->body)) {
        return op;
    }
    return LetStmt::make(op->name, std::move(value), std::move(body));
}
开发者ID:adityaatluri,项目名称:Halide,代码行数:9,代码来源:IRMutator.cpp

示例4: uses_branches

bool uses_branches(Func f) {
    Target t = get_jit_target_from_environment();
    t.set_feature(Target::NoBoundsQuery);
    t.set_feature(Target::NoAsserts);
    Stmt s = Internal::lower(f.function(), t);
    ContainsBranches b;
    s.accept(&b);
    return b.result;
}
开发者ID:josephwinston,项目名称:Halide,代码行数:9,代码来源:specialize_branched_loops.cpp

示例5: count_host_alignment_asserts

int count_host_alignment_asserts(Func f, std::map<string, int> m) {
    Target t = get_jit_target_from_environment();
    t.set_feature(Target::NoBoundsQuery);
    f.compute_root();
    Stmt s = Internal::lower({f.function()}, f.name(), t);
    CountHostAlignmentAsserts c(m);
    s.accept(&c);
    return c.count;
}
开发者ID:Mengke-Yuan,项目名称:Halide,代码行数:9,代码来源:host_alignment.cpp

示例6: Stmt

Stmt IRMutator::mutate(Stmt s) {
    if (s.defined()) {
        s.accept(this);
    } else {
        stmt = Stmt();
    }
    expr = Expr();
    return stmt;
}
开发者ID:JoeyJAL,项目名称:Halide,代码行数:9,代码来源:IRMutator.cpp

示例7: count_interleaves

int count_interleaves(Func f) {
    Target t = get_jit_target_from_environment();
    t.set_feature(Target::NoBoundsQuery);
    t.set_feature(Target::NoAsserts);
    Stmt s = Internal::lower(f.function(), t);
    CountInterleaves i;
    s.accept(&i);
    return i.result;
}
开发者ID:josephwinston,项目名称:Halide,代码行数:9,代码来源:interleave.cpp

示例8: while

  void NetworkDriverRewriteVisitor::InstrumentEntryPoints(FunctionDecl* funcDecl, string fdFile)
  {
    if (funcDecl->getStorageClass() == SC_Static)
      RW.RemoveText(funcDecl->getInnerLocStart(), 7);

    if (DI->getInstance().GetInitFunction() == funcDecl->getNameInfo().getName().getAsString())
      return;

    if (funcDecl->getParamDecl(0)->getOriginalType().getAsString() != "struct device *" &&
      funcDecl->getParamDecl(0)->getOriginalType().getAsString() != "struct pci_dev *")
      return;

    SourceRange sr = funcDecl->getParamDecl(0)->getSourceRange();

    RW.InsertTextBefore(sr.getBegin(), "struct net_device *dev, ");

    Stmt *body = funcDecl->getBody();
    list<DeclStmt*> stmtsToRewrite;

    for (auto i = body->child_begin(), e = body->child_end(); i != e; ++i)
    {
      if (!isa<DeclStmt>(*i))
        continue;

      DeclStmt *declStmt = cast<DeclStmt>(*i);
      if (!declStmt->isSingleDecl() && !isa<VarDecl>(declStmt->getSingleDecl()))
        continue;

      VarDecl *var = cast<VarDecl>(declStmt->getSingleDecl());
      if (!var->hasInit())
        continue;

      Expr *expr = var->getInit();
      if (!isa<ImplicitCastExpr>(expr))
        continue;

      ImplicitCastExpr *implicit = cast<ImplicitCastExpr>(expr);
      if (!isa<CallExpr>(implicit->getSubExpr()))
       continue;

      CallExpr *call = cast<CallExpr>(implicit->getSubExpr());
      DeclRefExpr *callee = cast<DeclRefExpr>(cast<ImplicitCastExpr>(call->getCallee())->getSubExpr());

      if (callee->getNameInfo().getName().getAsString() == "to_pci_dev" ||
          callee->getNameInfo().getName().getAsString() == "pci_get_drvdata")
      {
        stmtsToRewrite.push_back(declStmt);
      }
    }

    while (!stmtsToRewrite.empty())
    {
      DeclStmt *stmt = stmtsToRewrite.back();
      RW.RemoveText(stmt->getSourceRange());
      stmtsToRewrite.pop_back();
    }
  }
开发者ID:ITWOI,项目名称:chauffeur,代码行数:57,代码来源:NetworkDriverRewriteVisitor.cpp

示例9: isInComplexLoop

bool ReserveCandidates::isInComplexLoop(clang::Stmt *s, SourceLocation declLocation, bool isMemberVariable) const
{
    if (!s || declLocation.isInvalid())
        return false;

    int forCount = 0;
    int foreachCount = 0;

    static vector<unsigned int> nonComplexOnesCache;
    static vector<unsigned int> complexOnesCache;
    auto rawLoc = s->getLocStart().getRawEncoding();


    // For some reason we generate two warnings on some foreaches, so cache the ones we processed
    // and return true so we don't trigger a warning
    if (clazy_std::contains(nonComplexOnesCache, rawLoc) || clazy_std::contains(complexOnesCache, rawLoc))
        return true;

    Stmt *parent = s;
    PresumedLoc lastForeachForStm;
    while ((parent = HierarchyUtils::parent(m_parentMap, parent))) {
        const SourceLocation parentStart = parent->getLocStart();
        if (!isMemberVariable && sm().isBeforeInSLocAddrSpace(parentStart, declLocation)) {
            nonComplexOnesCache.push_back(rawLoc);
            return false;
        }

        bool isLoop = false;
        if (loopIsComplex(parent, isLoop)) {
            complexOnesCache.push_back(rawLoc);
            return true;
        }

        if (QtUtils::isInForeach(m_ci, parentStart)) {
            auto ploc = sm().getPresumedLoc(parentStart);
            if (Utils::presumedLocationsEqual(ploc, lastForeachForStm)) {
                // Q_FOREACH comes in pairs, because each has two for statements inside, so ignore one when counting
            } else {
                foreachCount++;
                lastForeachForStm = ploc;
            }
        } else {
            if (isLoop)
                forCount++;
        }

        if (foreachCount > 1 || forCount > 1) { // two foreaches are almost always a false-positve
            complexOnesCache.push_back(rawLoc);
            return true;
        }


    }

    nonComplexOnesCache.push_back(rawLoc);
    return false;
}
开发者ID:EugeneZelenko,项目名称:clazy,代码行数:57,代码来源:reservecandidates.cpp

示例10: Stmt

Stmt IRMutator::mutate(const Stmt &s) {
    if (s.defined()) {
        s.accept(this);
    } else {
        stmt = Stmt();
    }
    expr = Expr();
    return std::move(stmt);
}
开发者ID:adityaatluri,项目名称:Halide,代码行数:9,代码来源:IRMutator.cpp

示例11: print_vine_ir

void print_vine_ir(asm_program_t *prog, vector<vine_block_t *> vblocks )
{
    unsigned int i, j;
    
    for ( i = 0; i < vblocks.size(); i++ )
    {
        vine_block_t *block = vblocks.at(i);
        assert(block);
        
        vector<Stmt *> *inner = block->vine_ir;

	//        cout << "Vine Block " << i << endl;
        cout << "  {" << endl;
// 	declvis vis;
// 	vis.compute(inner);
// 	print_decls(vis.decls);
	//        cout << "    ";
	ostringstream os;
	ostream_insn(prog, block->inst, os);
	cout << "   // " << os.str() << endl;


	vector<VarDecl *> globals = get_reg_decls();
	map<string,reg_t> context;
        for(vector<VarDecl *>::const_iterator gi = globals.begin();
	    gi != globals.end(); gi++){
           VarDecl *vd = *gi;
           context.insert(pair<string, reg_t>(vd->name, vd->typ));
        }

        for ( j = 0; j < inner->size(); j++ )
        {
#ifdef TYPECHECKING
	  try {
	  if (typecheck_stmt(&context,  inner->at(j)) < 0) {
	    cout <<"Type error found at:" <<endl;
	  }
	  } catch (TypeError &e) {
	    cout <<"Type Error: " << e.what() <<endl;
	    cout <<"Found at:" <<endl;
	  }
#endif
	  Stmt *s = inner->at(j);
	  cout << "     " << s->tostring();
// 	  if(s->stmt_type == LABEL)
// 	    cout << endl;
// 	  else
// 	    cout << ";" << endl;
	  cout << endl;

        }
        cout << "  }" << endl;
    }
    
}
开发者ID:bengheng,项目名称:Expose,代码行数:55,代码来源:ir_printer.cpp

示例12: visit

 void visit(const For *for_loop) {
     Stmt body = mutate(for_loop->body);
     const IntImm *extent = for_loop->extent.as<IntImm>();
     if (extent && extent->value == 1) {
         stmt = new LetStmt(for_loop->name, for_loop->min, body);
     } else if (body.same_as(for_loop->body)) {
         stmt = for_loop;
     } else {
         stmt = new For(for_loop->name, for_loop->min, for_loop->extent, for_loop->for_type, body);
     }
 }
开发者ID:slippy0,项目名称:Halide,代码行数:11,代码来源:RemoveTrivialForLoops.cpp

示例13: mutate

void IRMutator::visit(const For *op) {
    Expr min = mutate(op->min);
    Expr extent = mutate(op->extent);
    Stmt body = mutate(op->body);
    if (min.same_as(op->min) &&
        extent.same_as(op->extent) &&
        body.same_as(op->body)) {
        stmt = op;
    } else {
        stmt = For::make(op->name, min, extent, op->for_type, body);
    }
}
开发者ID:JoeyJAL,项目名称:Halide,代码行数:12,代码来源:IRMutator.cpp

示例14: print_merged_ir

void print_merged_ir( vector<Stmt *> ir )
{
    unsigned int i;

    for ( i = 0; i < ir.size(); i++ )
    {
        Stmt *stmt = ir.at(i);
        assert(stmt);

        cout << stmt->ir_address << "\t\t" << stmt->tostring() << endl;
    }
}
开发者ID:AmesianX,项目名称:fuzzball,代码行数:12,代码来源:print-ir.cpp

示例15: make

Stmt Pipeline::make(std::string name, Stmt produce, Stmt update, Stmt consume) {
    internal_assert(produce.defined()) << "Pipeline of undefined\n";
    // update is allowed to be null
    internal_assert(consume.defined()) << "Pipeline of undefined\n";

    Pipeline *node = new Pipeline;
    node->name = name;
    node->produce = produce;
    node->update = update;
    node->consume = consume;
    return node;
}
开发者ID:JoeyJAL,项目名称:Halide,代码行数:12,代码来源:IR.cpp


注:本文中的Stmt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。