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


C++ Exp::AsFld方法代码示例

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


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

示例1: Visit

  void Visit(Exp *lval)
  {
    // match any access which uses a GC thing type as an rvalue,
    // including those where the thing is not actually dereferenced.
    // we are watching not just for direct accesses to the thing,
    // but to places where it is copied to arguments, a return value,
    // a variable or heap location. any use of an GC thing pointer
    // not protected against GC is considered to be an error, and adding
    // these asserts aggressively lets us discharge reports easier and
    // generate reports close to the site of the actual problem.

    if (!lval->IsDrf())
      return;
    ExpDrf *nlval = lval->AsDrf();

    Type *type = nlval->GetType();
    if (type && type->IsCSU() && TypeIsGCThing(type->AsCSU())) {
      AssertInfo info;
      info.kind = ASK_GCSafe;
      info.cls = ASC_Check;
      info.point = point;

      Exp *target = nlval->GetTarget();
      if (target->IsFld() &&
          BlockSummary::FieldIsGCSafe(target->AsFld()->GetField())) {
        info.bit = Bit::MakeConstant(true);
      } else {
        Exp *gcsafe = Exp::MakeGCSafe(nlval->GetTarget(), false);
        info.bit = Bit::MakeVar(gcsafe);
      }

      asserts.PushBack(info);
    }
  }
开发者ID:brifordwylie,项目名称:turnersr.github.io,代码行数:34,代码来源:infer.cpp

示例2: InferSummaries


//.........这里部分代码省略.........
        if (!annot_cfg) continue;

        if (annot_cfg->GetAnnotationKind() != AK_Assert &&
            annot_cfg->GetAnnotationKind() != AK_AssertRuntime) {
          continue;
        }

        if (Bit *bit = BlockMemory::GetAnnotationBit(annot_cfg)) {
          AssertInfo info;
          info.kind = (annot_cfg->GetAnnotationKind() == AK_Assert)
            ? ASK_Annotation : ASK_AnnotationRuntime;
          info.cls = ASC_Check;
          info.point = point;
          info.bit = bit;
          asserts.PushBack(info);
        }
      }

      // add assertions for any invariants affected by a write.

      Exp *left = NULL;
      if (PEdgeAssign *nedge = edge->IfAssign())
        left = nedge->GetLeftSide();
      if (PEdgeCall *nedge = edge->IfCall())
        left = nedge->GetReturnValue();

      // for now our detection of affected invariants is pretty crude;
      // writes to fields can affect type invariants on the field's type
      // which use that field, and writes to global variables can affect
      // invariants on that global. TODO: pin this down once we draw a
      // precise line between which invariants can and can't be checked.

      if (left && left->IsFld()) {
        ExpFld *nleft = left->AsFld();
        String *csu_name = nleft->GetField()->GetCSUType()->GetCSUName();
        Vector<BlockCFG*> *comp_annot_list = CompAnnotCache.Lookup(csu_name);

        for (size_t aind = 0; comp_annot_list &&
                              aind < comp_annot_list->Size(); aind++) {
          BlockCFG *annot_cfg = comp_annot_list->At(aind);

          if (annot_cfg->GetAnnotationKind() != AK_Invariant)
            continue;
          Bit *bit = BlockMemory::GetAnnotationBit(annot_cfg);
          if (!bit) continue;

          Vector<Exp*> lval_list;
          LvalListVisitor visitor(&lval_list);
          bit->DoVisit(&visitor);

          bool uses_field = false;
          for (size_t ind = 0; ind < lval_list.Size(); ind++) {
            if (ExpFld *lval = lval_list[ind]->IfFld()) {
              if (lval->GetField() == nleft->GetField())
                uses_field = true;
            }
          }

          if (uses_field) {
            // this is a type invariant which uses the field being written
            // as an lvalue. we need to assert this write preserves
            // the invariant.
            BlockId *id = annot_cfg->GetId();
            Variable *this_var = Variable::Make(id, VK_This, NULL, 0, NULL);
            Exp *this_exp = Exp::MakeVar(this_var);
            Exp *this_drf = Exp::MakeDrf(this_exp);
开发者ID:brifordwylie,项目名称:turnersr.github.io,代码行数:67,代码来源:infer.cpp


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