Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Sema/TreeTransform.h
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
//===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===// | //===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===// | ||||
Lint: Lint: clang-format not found in user's PATH; not linting file. | |||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// | // | ||||
// This file implements a semantic tree transformation that takes a given | // This file implements a semantic tree transformation that takes a given | ||||
▲ Show 20 Lines • Show All 1,597 Lines • ▼ Show 20 Lines | #include "llvm/Frontend/OpenMP/OMPKinds.def" | ||||
/// By default, performs semantic analysis to build the new OpenMP clause. | /// By default, performs semantic analysis to build the new OpenMP clause. | ||||
/// Subclasses may override this routine to provide different behavior. | /// Subclasses may override this routine to provide different behavior. | ||||
OMPClause *RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, | OMPClause *RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, | ||||
SourceLocation LParenLoc, | SourceLocation LParenLoc, | ||||
SourceLocation EndLoc) { | SourceLocation EndLoc) { | ||||
return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc); | return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc); | ||||
} | } | ||||
OMPClause *RebuildOMPSizesClause(ArrayRef<Expr *> Sizes, | |||||
SourceLocation StartLoc, | |||||
SourceLocation LParenLoc, | |||||
SourceLocation EndLoc) { | |||||
return getSema().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc, EndLoc); | |||||
} | |||||
/// Build a new OpenMP 'allocator' clause. | /// Build a new OpenMP 'allocator' clause. | ||||
/// | /// | ||||
/// By default, performs semantic analysis to build the new OpenMP clause. | /// By default, performs semantic analysis to build the new OpenMP clause. | ||||
/// Subclasses may override this routine to provide different behavior. | /// Subclasses may override this routine to provide different behavior. | ||||
OMPClause *RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, | OMPClause *RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, | ||||
SourceLocation LParenLoc, | SourceLocation LParenLoc, | ||||
SourceLocation EndLoc) { | SourceLocation EndLoc) { | ||||
return getSema().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc, EndLoc); | return getSema().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc, EndLoc); | ||||
▲ Show 20 Lines • Show All 6,690 Lines • ▼ Show 20 Lines | StmtResult TreeTransform<Derived>::TransformOMPExecutableDirective( | ||||
} | } | ||||
StmtResult AssociatedStmt; | StmtResult AssociatedStmt; | ||||
if (D->hasAssociatedStmt() && D->getAssociatedStmt()) { | if (D->hasAssociatedStmt() && D->getAssociatedStmt()) { | ||||
getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(), | getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(), | ||||
/*CurScope=*/nullptr); | /*CurScope=*/nullptr); | ||||
StmtResult Body; | StmtResult Body; | ||||
{ | { | ||||
Sema::CompoundScopeRAII CompoundScope(getSema()); | Sema::CompoundScopeRAII CompoundScope(getSema()); | ||||
Stmt *CS = D->getInnermostCapturedStmt()->getCapturedStmt(); | Stmt *CS = D->ignoreCaptures(); | ||||
Body = getDerived().TransformStmt(CS); | Body = getDerived().TransformStmt(CS); | ||||
} | } | ||||
AssociatedStmt = | AssociatedStmt = | ||||
getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses); | getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses); | ||||
if (AssociatedStmt.isInvalid()) { | if (AssociatedStmt.isInvalid()) { | ||||
return StmtError(); | return StmtError(); | ||||
} | } | ||||
} | } | ||||
Show All 38 Lines | getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr, | ||||
D->getBeginLoc()); | D->getBeginLoc()); | ||||
StmtResult Res = getDerived().TransformOMPExecutableDirective(D); | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); | ||||
getDerived().getSema().EndOpenMPDSABlock(Res.get()); | getDerived().getSema().EndOpenMPDSABlock(Res.get()); | ||||
return Res; | return Res; | ||||
} | } | ||||
template <typename Derived> | template <typename Derived> | ||||
StmtResult | StmtResult | ||||
TreeTransform<Derived>::TransformOMPTileDirective(OMPTileDirective *D) { | |||||
DeclarationNameInfo DirName; | |||||
getDerived().getSema().StartOpenMPDSABlock(D->getDirectiveKind(), DirName, | |||||
nullptr, D->getBeginLoc()); | |||||
StmtResult Res = getDerived().TransformOMPExecutableDirective(D); | |||||
getDerived().getSema().EndOpenMPDSABlock(Res.get()); | |||||
return Res; | |||||
} | |||||
template <typename Derived> | |||||
StmtResult | |||||
TreeTransform<Derived>::TransformOMPForDirective(OMPForDirective *D) { | TreeTransform<Derived>::TransformOMPForDirective(OMPForDirective *D) { | ||||
DeclarationNameInfo DirName; | DeclarationNameInfo DirName; | ||||
getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr, | getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr, | ||||
D->getBeginLoc()); | D->getBeginLoc()); | ||||
StmtResult Res = getDerived().TransformOMPExecutableDirective(D); | StmtResult Res = getDerived().TransformOMPExecutableDirective(D); | ||||
getDerived().getSema().EndOpenMPDSABlock(Res.get()); | getDerived().getSema().EndOpenMPDSABlock(Res.get()); | ||||
return Res; | return Res; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 625 Lines • ▼ Show 20 Lines | TreeTransform<Derived>::TransformOMPSimdlenClause(OMPSimdlenClause *C) { | ||||
ExprResult E = getDerived().TransformExpr(C->getSimdlen()); | ExprResult E = getDerived().TransformExpr(C->getSimdlen()); | ||||
if (E.isInvalid()) | if (E.isInvalid()) | ||||
return nullptr; | return nullptr; | ||||
return getDerived().RebuildOMPSimdlenClause( | return getDerived().RebuildOMPSimdlenClause( | ||||
E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); | ||||
} | } | ||||
template <typename Derived> | template <typename Derived> | ||||
OMPClause *TreeTransform<Derived>::TransformOMPSizesClause(OMPSizesClause *C) { | |||||
SmallVector<Expr *, 4> TransformedSizes; | |||||
TransformedSizes.reserve(C->getNumSizes()); | |||||
bool Changed = false; | |||||
for (Expr *E : C->getSizesRefs()) { | |||||
if (!E) { | |||||
TransformedSizes.push_back(nullptr); | |||||
continue; | |||||
} | |||||
ExprResult T = getDerived().TransformExpr(E); | |||||
if (T.isInvalid()) | |||||
return nullptr; | |||||
if (E != T.get()) | |||||
Changed = true; | |||||
TransformedSizes.push_back(T.get()); | |||||
} | |||||
if (!Changed && !getDerived().AlwaysRebuild()) | |||||
return C; | |||||
return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(), | |||||
C->getLParenLoc(), C->getEndLoc()); | |||||
} | |||||
template <typename Derived> | |||||
OMPClause * | OMPClause * | ||||
TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) { | TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) { | ||||
ExprResult E = getDerived().TransformExpr(C->getNumForLoops()); | ExprResult E = getDerived().TransformExpr(C->getNumForLoops()); | ||||
if (E.isInvalid()) | if (E.isInvalid()) | ||||
return nullptr; | return nullptr; | ||||
return getDerived().RebuildOMPCollapseClause( | return getDerived().RebuildOMPCollapseClause( | ||||
E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); | E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc()); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,342 Lines • Show Last 20 Lines |
clang-format not found in user's PATH; not linting file.