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


C++ StmtResult::isUsable方法代码示例

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


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

示例1: ParseMainProgram

/// ParseMainProgram - Parse the main program.
///
///   [R1101]:
///     main-program :=
///         [program-stmt]
///           [specification-part]
///           [execution-part]
///           [internal-subprogram-part]
///           end-program-stmt
bool Parser::ParseMainProgram(std::vector<StmtResult> &Body) {
  // If the PROGRAM statement didn't have an identifier, pretend like it did for
  // the time being.
  StmtResult ProgStmt;
  if (Tok.is(tok::kw_PROGRAM)) {
    ProgStmt = ParsePROGRAMStmt();
    Body.push_back(ProgStmt);
  }

  // If the PROGRAM statement has an identifier, pass it on to the main program
  // action.
  const IdentifierInfo *IDInfo = 0;
  SMLoc NameLoc;
  if (ProgStmt.isUsable()) {
    ProgramStmt *PS = ProgStmt.takeAs<ProgramStmt>();
    IDInfo = PS->getProgramName();
    NameLoc = PS->getNameLocation();
    // FIXME: Debugging
    dump(PS);
  }

  Actions.ActOnMainProgram(IDInfo, NameLoc);

  // FIXME: Check for the specific keywords and not just absence of END or
  //        ENDPROGRAM.
  ParseStatementLabel();
  if (Tok.isNot(tok::kw_END) && Tok.isNot(tok::kw_ENDPROGRAM))
    ParseSpecificationPart(Body);

  // FIXME: Check for the specific keywords and not just absence of END or
  //        ENDPROGRAM.
  ParseStatementLabel();
  if (Tok.isNot(tok::kw_END) && Tok.isNot(tok::kw_ENDPROGRAM))
    ParseExecutionPart(Body);

  // FIXME: Debugging support.
  dump(Body);

  ParseStatementLabel();
  StmtResult EndProgStmt = ParseEND_PROGRAMStmt();
  Body.push_back(EndProgStmt);

  IDInfo = 0;
  NameLoc = SMLoc();

  if (EndProgStmt.isUsable()) {
    EndProgramStmt *EPS = EndProgStmt.takeAs<EndProgramStmt>();
    IDInfo = EPS->getProgramName();
    NameLoc = EPS->getNameLocation();
  }

  Actions.ActOnEndMainProgram(IDInfo, NameLoc);
  return EndProgStmt.isInvalid();
}
开发者ID:isanbard,项目名称:flang,代码行数:63,代码来源:Parser.cpp

示例2: CheckStmtOrder

void Parser::CheckStmtOrder(SourceLocation Loc, StmtResult SR) {
  auto S = SR.get();
  if(SR.isUsable()) {
    if(Actions.InsideWhereConstruct(S))
      Actions.CheckValidWhereStmtPart(S);
  }

  if(PrevStmtWasSelectCase) {
    PrevStmtWasSelectCase = false;
    if(SR.isUsable() && (isa<SelectionCase>(S) ||
       (isa<ConstructPartStmt>(S) &&
        cast<ConstructPartStmt>(S)->getConstructStmtClass() == ConstructPartStmt::EndSelectStmtClass)))
      return;
    Diag.Report(SR.isUsable()? S->getLocation() : Loc,
                diag::err_expected_case_or_end_select);
  }
  if(SR.isUsable() && isa<SelectCaseStmt>(S))
    PrevStmtWasSelectCase = true;
}
开发者ID:carlobertolli,项目名称:flang,代码行数:19,代码来源:ParseExec.cpp

示例3: ParseSpecificationPart

/// ParseSpecificationPart - Parse the specification part.
///
///   [R204]:
///     specification-part :=
///        [use-stmt] ...
///          [import-stmt] ...
///          [implicit-part] ...
///          [declaration-construct] ...
bool Parser::ParseSpecificationPart(std::vector<StmtResult> &Body) {
  bool HasErrors = false;
  while (Tok.is(tok::kw_USE)) {
    StmtResult S = ParseUSEStmt();
    if (S.isUsable()) {
      Body.push_back(S);
    } else if (S.isInvalid()) {
      LexToEndOfStatement();
      HasErrors = true;
    } else {
      break;
    }

    ParseStatementLabel();
  }

  while (Tok.is(tok::kw_IMPORT)) {
    StmtResult S = ParseIMPORTStmt();
    if (S.isUsable()) {
      Body.push_back(S);
    } else if (S.isInvalid()) {
      LexToEndOfStatement();
      HasErrors = true;
    } else {
      break;
    }

    ParseStatementLabel();
  }

  if (ParseImplicitPartList(Body))
    HasErrors = true;

  if (ParseDeclarationConstructList()) {
    LexToEndOfStatement();
    HasErrors = true;
  }

  return HasErrors;
}
开发者ID:isanbard,项目名称:flang,代码行数:48,代码来源:Parser.cpp

示例4: ParseExecutableConstruct

/// ParseExecutableConstruct - Parse the executable construct.
///
///   [R213]:
///     executable-construct :=
///         action-stmt
///      or associate-construct
///      or block-construct
///      or case-construct
///      or critical-construct
///      or do-construct
///      or forall-construct
///      or if-construct
///      or select-type-construct
///      or where-construct
StmtResult Parser::ParseExecutableConstruct() {
  ParseStatementLabel();
  ParseConstructNameLabel();
  LookForExecutableStmtKeyword(StmtLabel || StmtConstructName.isUsable()?
                               false : true);

  auto Loc = Tok.getLocation();
  StmtResult SR = ParseActionStmt();
  CheckStmtOrder(Loc, SR);
  if (SR.isInvalid()) return StmtError();
  if (!SR.isUsable()) return StmtResult();

  return SR;
}
开发者ID:carlobertolli,项目名称:flang,代码行数:28,代码来源:ParseExec.cpp

示例5: ParseExecutionPart

/// ParseExecutionPart - Parse the execution part.
///
///   [R208]:
///     execution-part :=
///         executable-construct
///           [ execution-part-construct ] ...
bool Parser::ParseExecutionPart(std::vector<StmtResult> &Body) {
  bool HadError = false;
  while (true) {
    StmtResult SR = ParseExecutableConstruct();
    if (SR.isInvalid()) {
      LexToEndOfStatement();
      HadError = true;
    } else if (!SR.isUsable()) {
      break;
    }
    Body.push_back(SR);
  }

  return HadError;
}
开发者ID:isanbard,项目名称:flang,代码行数:21,代码来源:Parser.cpp

示例6: ParseImplicitPartList

/// ParseImplicitPartList - Parse a (possibly empty) list of implicit part
/// statements.
bool Parser::ParseImplicitPartList(std::vector<StmtResult> &Body) {
  bool HasErrors = false;
  while (true) {
    StmtResult S = ParseImplicitPart();
    if (S.isUsable()) {
      Body.push_back(S);
    } else if (S.isInvalid()) {
      LexToEndOfStatement();
      HasErrors = true;
    } else {
      break;
    }
  }

  return HasErrors;
}
开发者ID:isanbard,项目名称:flang,代码行数:18,代码来源:Parser.cpp

示例7: ParseOpenMPDeclarativeOrExecutableDirective

/// \brief Parsing of declarative or executable OpenMP directives.
///
///       threadprivate-directive:
///         annot_pragma_openmp 'threadprivate' simple-variable-list
///         annot_pragma_openmp_end
///
///       parallel-directive:
///         annot_pragma_openmp 'parallel' {clause} annot_pragma_openmp_end
///
StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective() {
  assert(Tok.is(tok::annot_pragma_openmp) && "Not an OpenMP directive!");
  ParenBraceBracketBalancer BalancerRAIIObj(*this);
  SmallVector<Expr *, 5> Identifiers;
  SmallVector<OMPClause *, 5> Clauses;
  SmallVector<llvm::PointerIntPair<OMPClause *, 1, bool>, NUM_OPENMP_CLAUSES>
                                               FirstClauses(NUM_OPENMP_CLAUSES);
  const unsigned ScopeFlags = Scope::FnScope | Scope::DeclScope |
                              Scope::OpenMPDirectiveScope;
  SourceLocation Loc = ConsumeToken(), EndLoc;
  OpenMPDirectiveKind DKind = Tok.isAnnotation() ?
                                  OMPD_unknown :
                                  getOpenMPDirectiveKind(PP.getSpelling(Tok));
  // Name of critical directive.
  DeclarationNameInfo DirName;
  StmtResult Directive = StmtError();

  switch (DKind) {
  case OMPD_threadprivate:
    ConsumeToken();
    if (!ParseOpenMPSimpleVarList(OMPD_threadprivate, Identifiers, false)) {
      // The last seen token is annot_pragma_openmp_end - need to check for
      // extra tokens.
      if (Tok.isNot(tok::annot_pragma_openmp_end)) {
        Diag(Tok, diag::warn_omp_extra_tokens_at_eol)
          << getOpenMPDirectiveName(OMPD_threadprivate);
        SkipUntil(tok::annot_pragma_openmp_end, StopBeforeMatch);
      }
      DeclGroupPtrTy Res =
        Actions.ActOnOpenMPThreadprivateDirective(Loc,
                                                  Identifiers);
      Directive = Actions.ActOnDeclStmt(Res, Loc, Tok.getLocation());
    }
    SkipUntil(tok::annot_pragma_openmp_end);
    break;
  case OMPD_parallel: {
    ConsumeToken();

    Actions.StartOpenMPDSABlock(DKind, DirName, Actions.getCurScope());

    while (Tok.isNot(tok::annot_pragma_openmp_end)) {
      OpenMPClauseKind CKind = Tok.isAnnotation() ?
                                  OMPC_unknown :
                                  getOpenMPClauseKind(PP.getSpelling(Tok));
      OMPClause *Clause = ParseOpenMPClause(DKind, CKind,
                                            !FirstClauses[CKind].getInt());
      FirstClauses[CKind].setInt(true);
      if (Clause) {
        FirstClauses[CKind].setPointer(Clause);
        Clauses.push_back(Clause);
      }

      // Skip ',' if any.
      if (Tok.is(tok::comma))
        ConsumeToken();
    }
    // End location of the directive.
    EndLoc = Tok.getLocation();
    // Consume final annot_pragma_openmp_end.
    ConsumeToken();

    StmtResult AssociatedStmt;
    bool CreateDirective = true;
    ParseScope OMPDirectiveScope(this, ScopeFlags);
    {
      // The body is a block scope like in Lambdas and Blocks.
      Sema::CompoundScopeRAII CompoundScope(Actions);
      Actions.ActOnCapturedRegionStart(Loc, getCurScope(), CR_OpenMP, 1);
      Actions.ActOnStartOfCompoundStmt();
      // Parse statement
      AssociatedStmt = ParseStatement();
      Actions.ActOnFinishOfCompoundStmt();
      if (!AssociatedStmt.isUsable()) {
        Actions.ActOnCapturedRegionError();
        CreateDirective = false;
      } else {
        AssociatedStmt = Actions.ActOnCapturedRegionEnd(AssociatedStmt.take());
        CreateDirective = AssociatedStmt.isUsable();
      }
    }
    if (CreateDirective)
      Directive = Actions.ActOnOpenMPExecutableDirective(DKind, Clauses,
                                                         AssociatedStmt.take(),
                                                         Loc, EndLoc);

    // Exit scope.
    Actions.EndOpenMPDSABlock(Directive.get());
    OMPDirectiveScope.Exit();
    }
    break;
  case OMPD_unknown:
//.........这里部分代码省略.........
开发者ID:gix,项目名称:clang,代码行数:101,代码来源:ParseOpenMP.cpp

示例8: ParseSAVEStmt

/// ParseSAVEStmt - Parse the SAVE statement.
///
///   [R543]:
///     save-stmt :=
///         SAVE [ [::] saved-entity-list ]
Parser::StmtResult Parser::ParseSAVEStmt() {
  // Check if this is an assignment.
  if (IsNextToken(tok::equal))
    return StmtResult();

  auto Loc = ConsumeToken();
  if(Tok.isAtStartOfStatement())
    return Actions.ActOnSAVE(Context, Loc, StmtLabel);

  bool IsSaveStmt = ConsumeIfPresent(tok::coloncolon);
  SmallVector<Stmt *,8> StmtList;
  bool ListParsedOk = true;

  auto IDLoc = Tok.getLocation();
  auto II = Tok.getIdentifierInfo();
  StmtResult Stmt;
  if(ConsumeIfPresent(tok::slash)) {
    IDLoc = Tok.getLocation();
    II = Tok.getIdentifierInfo();
    if(ExpectAndConsume(tok::identifier)) {
      if(!ExpectAndConsume(tok::slash))
        ListParsedOk = false;
      Stmt = Actions.ActOnSAVECommonBlock(Context, Loc, IDLoc, II);
    }
    else ListParsedOk = false;
  }
  else if(ExpectAndConsume(tok::identifier)) {
    if(!IsSaveStmt && Features.FixedForm && (IsPresent(tok::equal) || IsPresent(tok::l_paren)))
      return ReparseAmbiguousAssignmentStatement();
    Stmt = Actions.ActOnSAVE(Context, Loc, IDLoc, II, nullptr);
  } else ListParsedOk = false;

  if(Stmt.isUsable())
    StmtList.push_back(Stmt.get());
  if(ListParsedOk) {
    while(ConsumeIfPresent(tok::comma)) {
      IDLoc = Tok.getLocation();
      II = Tok.getIdentifierInfo();
      if(ConsumeIfPresent(tok::slash)) {
        IDLoc = Tok.getLocation();
        II = Tok.getIdentifierInfo();
        if(!ExpectAndConsume(tok::identifier)) {
          ListParsedOk = false;
          break;
        }
        if(!ExpectAndConsume(tok::slash)) {
          ListParsedOk = false;
          break;
        }
        Stmt = Actions.ActOnSAVECommonBlock(Context, Loc, IDLoc, II);
      }
      else if(ExpectAndConsume(tok::identifier))
        Stmt = Actions.ActOnSAVE(Context, Loc, IDLoc, II, nullptr);
      else {
        ListParsedOk = false;
        break;
      }

      if(Stmt.isUsable())
        StmtList.push_back(Stmt.get());
    }
  }

  if(ListParsedOk) ExpectStatementEnd();
  else SkipUntilNextStatement();

  return Actions.ActOnCompoundStmt(Context, Loc, StmtList, StmtLabel);
}
开发者ID:carlobertolli,项目名称:flang,代码行数:73,代码来源:ParseSpecStmt.cpp


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