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


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

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


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

示例1: Visit

  void Visit(Exp *lval)
  {
    // buffer which is being accessed.
    Exp *base = NULL;

    // element type of the buffer.
    Type *elem_type = NULL;

    // index of the buffer being accessed.
    Exp *index = NULL;

    // peel off any leading fields.
    while (ExpFld *nlval = lval->IfFld())
      lval = nlval->GetTarget();

    if (ExpIndex *nlval = lval->IfIndex()) {
      base = nlval->GetTarget();
      elem_type = nlval->GetElementType();
      index = nlval->GetIndex();

      if (base->IsIndex()) {
        // multidimensional array access, the base needs to be checked
        // if we are looking for reads.
        if (!check_writes)
          Visit(base);
      }
    }

    if (ExpDrf *nlval = lval->IfDrf()) {
      // see if this expression is in the values we know might be the result
      // of pointer arithmetic.
      bool is_arithmetic = false;

      if (Exp *new_lval = Trace::SanitizeExp(lval))
        is_arithmetic = arithmetic_list.Contains(new_lval);

      if (is_arithmetic) {
        base = lval;

        elem_type = nlval->GetType();
        if (!elem_type) {
          // TODO: need better handling for this case. *((int*)n)
          elem_type = Type::MakeVoid();
        }

        index = Exp::MakeInt(0);
      }
    }

    if (base || elem_type || index) {
      Assert(base && elem_type && index);

      AssertInfo lower_info;
      AssertInfo upper_info;

      lower_info.kind = check_writes ? ASK_WriteUnderflow : ASK_ReadUnderflow;
      upper_info.kind = check_writes ? ASK_WriteOverflow : ASK_ReadOverflow;

      lower_info.cls = ASC_Check;
      upper_info.cls = ASC_Check;

      lower_info.point = point;
      upper_info.point = point;

      Exp *lbound = Exp::MakeBound(BND_Lower, base, elem_type);
      lower_info.bit = Exp::MakeCompareBit(B_GreaterEqual, index, lbound);

      Exp *ubound = Exp::MakeBound(BND_Upper, base, elem_type);
      upper_info.bit = Exp::MakeCompareBit(B_LessThan, index, ubound);

      // if we are looking for reads, only add if there is not already
      // an equivalent write (we add writes to the assert list first).
      // this will obscure the reads in statements like '(*p)++', oh well.

      bool skip_lower = false;
      bool skip_upper = false;

      // don't restrict just to reads here, so that this works as a general
      // purpose dupe-remover.
      for (size_t ind = 0; ind < asserts.Size(); ind++) {
        const AssertInfo &info = asserts[ind];
        if (info.point == point && info.bit == lower_info.bit)
          skip_lower = true;
        if (info.point == point && info.bit == upper_info.bit)
          skip_upper = true;
      }

      if (!skip_lower)
        asserts.PushBack(lower_info);

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


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