================ @@ -5965,6 +5967,244 @@ static bool teamsLoopCanBeParallelFor(Stmt *AStmt, Sema &SemaRef) { return Checker.teamsLoopCanBeParallelFor(); } +static Expr *getInitialExprFromCapturedExpr(Expr *Cond) { + + Expr *SubExpr = Cond->IgnoreParenImpCasts(); + + if (auto *DeclRef = dyn_cast<DeclRefExpr>(SubExpr)) { + if (auto *CapturedExprDecl = + dyn_cast<OMPCapturedExprDecl>(DeclRef->getDecl())) { + + // Retrieve the initial expression from the captured expression + return CapturedExprDecl->getInit(); + } + } + return nullptr; +} + +static Expr *copy_removePseudoObjectExpr(const ASTContext &Context, Expr *E, + SemaOpenMP *SemaPtr, bool NoContext) { + + BinaryOperator *BinaryCopyOpr = NULL; + bool BinaryOp = false; + if (E->getStmtClass() == Stmt::BinaryOperatorClass) { + BinaryOp = true; + BinaryOperator *E_BinOpr = static_cast<BinaryOperator *>(E); + BinaryCopyOpr = BinaryOperator::Create( + Context, E_BinOpr->getLHS(), E_BinOpr->getRHS(), E_BinOpr->getOpcode(), + E_BinOpr->getType(), E_BinOpr->getValueKind(), + E_BinOpr->getObjectKind(), E_BinOpr->getOperatorLoc(), + FPOptionsOverride()); + E = BinaryCopyOpr->getRHS(); + } + + // Change PseudoObjectExpr to a direct call + if (PseudoObjectExpr *PO = dyn_cast<PseudoObjectExpr>(E)) + E = *((PO->semantics_begin()) - 1); + + // Add new Traits to direct call to convert it to new PseudoObjectExpr + // This converts Traits for the function call from under "dispatch" to traits + // of direct function call not under "dispatch". + if (NoContext) { + // Convert StmtResult to a CallExpr before calling ActOnOpenMPCall() + CallExpr *CallExprWithinStmt = dyn_cast<CallExpr>(E); + int NumArgs = CallExprWithinStmt->getNumArgs(); + clang::Expr **Args = CallExprWithinStmt->getArgs(); + ExprResult er = SemaPtr->ActOnOpenMPCall( + CallExprWithinStmt, SemaPtr->SemaRef.getCurScope(), + CallExprWithinStmt->getBeginLoc(), MultiExprArg(Args, NumArgs), + CallExprWithinStmt->getRParenLoc(), static_cast<Expr *>(nullptr)); + E = er.get(); + } + + if (BinaryOp) { + BinaryCopyOpr->setRHS(E); + return BinaryCopyOpr; + } + + return E; +} + +static StmtResult combine2Stmts(ASTContext &context, Stmt *first, + Stmt *second) { ---------------- alexey-bataev wrote:
Variable names do not match coding standard https://github.com/llvm/llvm-project/pull/117904 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits