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


C++ Counter::getExpressionID方法代码示例

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


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

示例1: dump

void CounterMappingContext::dump(const Counter &C,
                                 llvm::raw_ostream &OS) const {
  switch (C.getKind()) {
  case Counter::Zero:
    OS << '0';
    return;
  case Counter::CounterValueReference:
    OS << '#' << C.getCounterID();
    break;
  case Counter::Expression: {
    if (C.getExpressionID() >= Expressions.size())
      return;
    const auto &E = Expressions[C.getExpressionID()];
    OS << '(';
    dump(E.LHS, OS);
    OS << (E.Kind == CounterExpression::Subtract ? " - " : " + ");
    dump(E.RHS, OS);
    OS << ')';
    break;
  }
  }
  if (CounterValues.empty())
    return;
  ErrorOr<int64_t> Value = evaluate(C);
  if (!Value)
    return;
  OS << '[' << *Value << ']';
}
开发者ID:dongAxis,项目名称:clang-700.0.72,代码行数:28,代码来源:CoverageMapping.cpp

示例2: evaluate

int64_t CounterMappingContext::evaluate(const Counter &C,
                                        std::error_code *EC) const {
  switch (C.getKind()) {
  case Counter::Zero:
    return 0;
  case Counter::CounterValueReference:
    if (C.getCounterID() >= CounterValues.size()) {
      if (EC)
        *EC = std::make_error_code(std::errc::argument_out_of_domain);
      break;
    }
    return CounterValues[C.getCounterID()];
  case Counter::Expression: {
    if (C.getExpressionID() >= Expressions.size()) {
      if (EC)
        *EC = std::make_error_code(std::errc::argument_out_of_domain);
      break;
    }
    const auto &E = Expressions[C.getExpressionID()];
    auto LHS = evaluate(E.LHS, EC);
    if (EC && *EC)
      return 0;
    auto RHS = evaluate(E.RHS, EC);
    if (EC && *EC)
      return 0;
    return E.Kind == CounterExpression::Subtract ? LHS - RHS : LHS + RHS;
  }
  }
  return 0;
}
开发者ID:AntiMoron,项目名称:llvm,代码行数:30,代码来源:CoverageMapping.cpp

示例3: PrintTo

void PrintTo(const Counter &C, ::std::ostream *os) {
  if (C.isZero())
    *os << "Zero";
  else if (C.isExpression())
    *os << "Expression " << C.getExpressionID();
  else
    *os << "Counter " << C.getCounterID();
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例4: make_error_code

ErrorOr<int64_t> CounterMappingContext::evaluate(const Counter &C) const {
  switch (C.getKind()) {
  case Counter::Zero:
    return 0;
  case Counter::CounterValueReference:
    if (C.getCounterID() >= CounterValues.size())
      return std::make_error_code(std::errc::argument_out_of_domain);
    return CounterValues[C.getCounterID()];
  case Counter::Expression: {
    if (C.getExpressionID() >= Expressions.size())
      return std::make_error_code(std::errc::argument_out_of_domain);
    const auto &E = Expressions[C.getExpressionID()];
    ErrorOr<int64_t> LHS = evaluate(E.LHS);
    if (!LHS)
      return LHS;
    ErrorOr<int64_t> RHS = evaluate(E.RHS);
    if (!RHS)
      return RHS;
    return E.Kind == CounterExpression::Subtract ? *LHS - *RHS : *LHS + *RHS;
  }
  }
  llvm_unreachable("Unhandled CounterKind");
}
开发者ID:dongAxis,项目名称:clang-700.0.72,代码行数:23,代码来源:CoverageMapping.cpp

示例5: extractTerms

void CounterExpressionBuilder::extractTerms(Counter C, int Sign) {
  switch (C.getKind()) {
  case Counter::Zero:
    break;
  case Counter::CounterValueReference:
    Terms[C.getCounterID()] += Sign;
    break;
  case Counter::Expression:
    const auto &E = Expressions[C.getExpressionID()];
    extractTerms(E.LHS, Sign);
    extractTerms(E.RHS, E.Kind == CounterExpression::Subtract ? -Sign : Sign);
    break;
  }
}
开发者ID:AntiMoron,项目名称:llvm,代码行数:14,代码来源:CoverageMapping.cpp

示例6: extractTerms

void CounterExpressionBuilder::extractTerms(
    Counter C, int Sign, SmallVectorImpl<std::pair<unsigned, int>> &Terms) {
  switch (C.getKind()) {
  case Counter::Zero:
    break;
  case Counter::CounterValueReference:
    Terms.push_back(std::make_pair(C.getCounterID(), Sign));
    break;
  case Counter::Expression:
    const auto &E = Expressions[C.getExpressionID()];
    extractTerms(E.LHS, Sign, Terms);
    extractTerms(E.RHS, E.Kind == CounterExpression::Subtract ? -Sign : Sign,
                 Terms);
    break;
  }
}
开发者ID:dongAxis,项目名称:clang-700.0.72,代码行数:16,代码来源:CoverageMapping.cpp

示例7: extractTerms

void CounterExpressionBuilder::extractTerms(Counter C, int Factor,
                                            SmallVectorImpl<Term> &Terms) {
  switch (C.getKind()) {
  case Counter::Zero:
    break;
  case Counter::CounterValueReference:
    Terms.emplace_back(C.getCounterID(), Factor);
    break;
  case Counter::Expression:
    const auto &E = Expressions[C.getExpressionID()];
    extractTerms(E.LHS, Factor, Terms);
    extractTerms(
        E.RHS, E.Kind == CounterExpression::Subtract ? -Factor : Factor, Terms);
    break;
  }
}
开发者ID:MatthiasJReisinger,项目名称:llvm,代码行数:16,代码来源:CoverageMapping.cpp


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