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


C++ Stmt::getStmtClass方法代码示例

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


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

示例1: getFromNode

ASTNodeKind ASTNodeKind::getFromNode(const Stmt &S) {
  switch (S.getStmtClass()) {
    case Stmt::NoStmtClass: return NKI_None;
#define STMT(CLASS, PARENT)                                                    \
    case Stmt::CLASS##Class: return ASTNodeKind(NKI_##CLASS);
#define ABSTRACT_STMT(S)
#include "clang/AST/StmtNodes.inc"
  }
  llvm_unreachable("invalid stmt kind");
}
开发者ID:Aj0Ay,项目名称:clang,代码行数:10,代码来源:ASTTypeTraits.cpp

示例2: isConsumedExpr

bool ParentMap::isConsumedExpr(Expr* E) const {
  Stmt *P = getParent(E);
  Stmt *DirectChild = E;

  // Ignore parents that don't guarantee consumption.
  while (P && (isa<ParenExpr>(P) || isa<CastExpr>(P) ||
               isa<ExprWithCleanups>(P))) {
    DirectChild = P;
    P = getParent(P);
  }

  if (!P)
    return false;

  switch (P->getStmtClass()) {
    default:
      return isa<Expr>(P);
    case Stmt::DeclStmtClass:
      return true;
    case Stmt::BinaryOperatorClass: {
      BinaryOperator *BE = cast<BinaryOperator>(P);
      // If it is a comma, only the right side is consumed.
      // If it isn't a comma, both sides are consumed.
      return BE->getOpcode()!=BO_Comma ||DirectChild==BE->getRHS();
    }
    case Stmt::ForStmtClass:
      return DirectChild == cast<ForStmt>(P)->getCond();
    case Stmt::WhileStmtClass:
      return DirectChild == cast<WhileStmt>(P)->getCond();
    case Stmt::DoStmtClass:
      return DirectChild == cast<DoStmt>(P)->getCond();
    case Stmt::IfStmtClass:
      return DirectChild == cast<IfStmt>(P)->getCond();
    case Stmt::IndirectGotoStmtClass:
      return DirectChild == cast<IndirectGotoStmt>(P)->getTarget();
    case Stmt::SwitchStmtClass:
      return DirectChild == cast<SwitchStmt>(P)->getCond();
    case Stmt::ObjCForCollectionStmtClass:
      return DirectChild == cast<ObjCForCollectionStmt>(P)->getCollection();
    case Stmt::ReturnStmtClass:
      return true;
  }
}
开发者ID:jaredmcneill,项目名称:netbsd-src,代码行数:43,代码来源:ParentMap.cpp

示例3: while

Stmt * FakeDirectiveHandler::getParent(Stmt * Base) {

  // Get parent stmt:
  Stmt * Parent = Base;
  
  while((Parent = dyn_cast<clang::Stmt>(PM->getParent(Parent)))) {

    // Wanted: CompoundStmt, ForStmt, IfStmt, WhileStmt, DoStmt, SwitchStmt
    // Ignore: CaseStmt, DefaultStmt
    // Ignore But Don't Expect: BreakStmt, ContinueStmt, NullStmt
    // Ignore With Big Warnings: Every other stmt
    
    switch(Parent->getStmtClass()) {
    
     case Stmt::CompoundStmtClass:
     case Stmt::ForStmtClass:
     case Stmt::IfStmtClass:
     case Stmt::WhileStmtClass:
     case Stmt::DoStmtClass:
     case Stmt::SwitchStmtClass:
      return Parent;
     case Stmt::CaseStmtClass:
     case Stmt::DefaultStmtClass:
     case Stmt::ReturnStmtClass:
      break;
     case Stmt::BreakStmtClass:
     case Stmt::ContinueStmtClass:
     case Stmt::NullStmtClass:
     default:
      llvm::errs() << "Warning; Unexpected Parent Stmt Type\n";
    }

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


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