clang  3.7.0
Macros | Enumerations | Functions
SemaOpenMP.cpp File Reference

This file implements semantic analysis for OpenMP directives and clauses. More...

#include "TreeTransform.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/OpenMPKinds.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaInternal.h"
Include dependency graph for SemaOpenMP.cpp:

Go to the source code of this file.

Macros

#define DSAStack   static_cast<DSAStackTy *>(VarDataSharingAttributesStack)
 

Enumerations

enum  DefaultDataSharingAttributes
 Default data sharing attributes, which can be applied to directive. More...
 

Functions

static VarDeclbuildVarDecl (Sema &SemaRef, SourceLocation Loc, QualType Type, StringRef Name)
 Build a variable declaration for OpenMP loop iteration variable. More...
 
static DeclRefExprbuildDeclRefExpr (Sema &S, VarDecl *D, QualType Ty, SourceLocation Loc, bool RefersToCapture=false)
 
static bool FinishOpenMPLinearClause (OMPLinearClause &Clause, DeclRefExpr *IV, Expr *NumIterations, Sema &SemaRef, Scope *S)
 
static void ReportOriginalDSA (Sema &SemaRef, DSAStackTy *Stack, const VarDecl *VD, DSAStackTy::DSAVarData DVar, bool IsLoopIterVar=false)
 
static bool CheckNestingOfRegions (Sema &SemaRef, DSAStackTy *Stack, OpenMPDirectiveKind CurrentRegion, const DeclarationNameInfo &CurrentName, OpenMPDirectiveKind CancelRegion, SourceLocation StartLoc)
 
static bool CheckOpenMPIterationSpace (OpenMPDirectiveKind DKind, Stmt *S, Sema &SemaRef, DSAStackTy &DSA, unsigned CurrentNestedLoopCount, unsigned NestedLoopCount, Expr *NestedLoopCountExpr, llvm::DenseMap< VarDecl *, Expr * > &VarsWithImplicitDSA, LoopIterationSpace &ResultIterSpace)
 Called on a for stmt to check and extract its iteration space for further processing (such as collapsing). More...
 
static ExprResult BuildCounterInit (Sema &SemaRef, Scope *S, SourceLocation Loc, ExprResult VarRef, ExprResult Start)
 Build 'VarRef = Start. More...
 
static ExprResult BuildCounterUpdate (Sema &SemaRef, Scope *S, SourceLocation Loc, ExprResult VarRef, ExprResult Start, ExprResult Iter, ExprResult Step, bool Subtract)
 Build 'VarRef = Start + Iter * Step'. More...
 
static ExprResult WidenIterationCount (unsigned Bits, Expr *E, Sema &SemaRef)
 Convert integer expression E to make it have at least Bits bits. More...
 
static bool FitsInto (unsigned Bits, bool Signed, Expr *E, Sema &SemaRef)
 Check if the given expression E is a constant integer that fits into Bits bits. More...
 
static unsigned CheckOpenMPLoop (OpenMPDirectiveKind DKind, Expr *NestedLoopCountExpr, Stmt *AStmt, Sema &SemaRef, DSAStackTy &DSA, llvm::DenseMap< VarDecl *, Expr * > &VarsWithImplicitDSA, OMPLoopDirective::HelperExprs &Built)
 Called on a for stmt to check itself and nested loops (if any). More...
 
static ExprGetCollapseNumberExpr (ArrayRef< OMPClause * > Clauses)
 

Detailed Description

This file implements semantic analysis for OpenMP directives and clauses.

Definition in file SemaOpenMP.cpp.

Macro Definition Documentation

#define DSAStack   static_cast<DSAStackTy *>(VarDataSharingAttributesStack)

Definition at line 656 of file SemaOpenMP.cpp.

Referenced by clang::Sema::ActOnOpenMPAlignedClause(), clang::Sema::ActOnOpenMPCancelDirective(), clang::Sema::ActOnOpenMPCancellationPointDirective(), clang::Sema::ActOnOpenMPCopyinClause(), clang::Sema::ActOnOpenMPCopyprivateClause(), clang::Sema::ActOnOpenMPDefaultClause(), clang::Sema::ActOnOpenMPExecutableDirective(), clang::Sema::ActOnOpenMPFinalClause(), clang::Sema::ActOnOpenMPFirstprivateClause(), clang::Sema::ActOnOpenMPForDirective(), clang::Sema::ActOnOpenMPForSimdDirective(), clang::Sema::ActOnOpenMPIdExpression(), clang::Sema::ActOnOpenMPIfClause(), clang::Sema::ActOnOpenMPLastprivateClause(), clang::Sema::ActOnOpenMPLinearClause(), clang::Sema::ActOnOpenMPLoopInitialization(), clang::Sema::ActOnOpenMPNowaitClause(), clang::Sema::ActOnOpenMPOrderedClause(), clang::Sema::ActOnOpenMPParallelForDirective(), clang::Sema::ActOnOpenMPParallelForSimdDirective(), clang::Sema::ActOnOpenMPPrivateClause(), clang::Sema::ActOnOpenMPReductionClause(), clang::Sema::ActOnOpenMPRegionEnd(), clang::Sema::ActOnOpenMPRegionStart(), clang::Sema::ActOnOpenMPScheduleClause(), clang::Sema::ActOnOpenMPSharedClause(), clang::Sema::ActOnOpenMPSimdDirective(), clang::Sema::ActOnOpenMPTargetDirective(), clang::Sema::CheckOMPThreadPrivateDecl(), clang::Sema::EndOpenMPClause(), clang::Sema::EndOpenMPDSABlock(), clang::Sema::IsOpenMPCapturedVar(), clang::Sema::isOpenMPPrivateVar(), clang::Sema::StartOpenMPClause(), and clang::Sema::StartOpenMPDSABlock().

Enumeration Type Documentation

Default data sharing attributes, which can be applied to directive.

Definition at line 40 of file SemaOpenMP.cpp.

Function Documentation

static ExprResult BuildCounterInit ( Sema SemaRef,
Scope S,
SourceLocation  Loc,
ExprResult  VarRef,
ExprResult  Start 
)
static
static ExprResult BuildCounterUpdate ( Sema SemaRef,
Scope S,
SourceLocation  Loc,
ExprResult  VarRef,
ExprResult  Start,
ExprResult  Iter,
ExprResult  Step,
bool  Subtract 
)
static
static DeclRefExpr* buildDeclRefExpr ( Sema S,
VarDecl D,
QualType  Ty,
SourceLocation  Loc,
bool  RefersToCapture = false 
)
static
static VarDecl* buildVarDecl ( Sema SemaRef,
SourceLocation  Loc,
QualType  Type,
StringRef  Name 
)
static
static bool CheckNestingOfRegions ( Sema SemaRef,
DSAStackTy *  Stack,
OpenMPDirectiveKind  CurrentRegion,
const DeclarationNameInfo CurrentName,
OpenMPDirectiveKind  CancelRegion,
SourceLocation  StartLoc 
)
static
static bool CheckOpenMPIterationSpace ( OpenMPDirectiveKind  DKind,
Stmt S,
Sema SemaRef,
DSAStackTy &  DSA,
unsigned  CurrentNestedLoopCount,
unsigned  NestedLoopCount,
Expr NestedLoopCountExpr,
llvm::DenseMap< VarDecl *, Expr * > &  VarsWithImplicitDSA,
LoopIterationSpace &  ResultIterSpace 
)
static
static unsigned CheckOpenMPLoop ( OpenMPDirectiveKind  DKind,
Expr NestedLoopCountExpr,
Stmt AStmt,
Sema SemaRef,
DSAStackTy &  DSA,
llvm::DenseMap< VarDecl *, Expr * > &  VarsWithImplicitDSA,
OMPLoopDirective::HelperExprs Built 
)
static

Called on a for stmt to check itself and nested loops (if any).

Returns
Returns 0 if one of the collapsed stmts is not canonical for loop, number of collapsed loops otherwise.

Definition at line 3094 of file SemaOpenMP.cpp.

References clang::Sema::AA_Converting, clang::Sema::ActOnConditionalOp(), clang::Sema::ActOnFinishFullExpr(), clang::Sema::ActOnIntegerConstant(), clang::Sema::ActOnParenExpr(), clang::Sema::AddInitializerToDecl(), clang::BO_Add, clang::BO_Assign, clang::BO_Div, clang::BO_GT, clang::BO_LAnd, clang::BO_LT, clang::BO_Mul, clang::BO_Rem, clang::BO_Sub, clang::Sema::BuildBinOp(), BuildCounterInit(), BuildCounterUpdate(), buildDeclRefExpr(), buildVarDecl(), AttributeLangSupport::C, clang::OMPLoopDirective::HelperExprs::CalcLastIteration, CheckOpenMPIterationSpace(), clang::OMPLoopDirective::HelperExprs::clear(), clang::OMPLoopDirective::HelperExprs::Cond, clang::Sema::Context, clang::OMPLoopDirective::HelperExprs::Counters, clang::Sema::CurContext, clang::OMPLoopDirective::HelperExprs::EUB, clang::Expr::EvaluateAsInt(), clang::OMPLoopDirective::HelperExprs::Finals, FitsInto(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Sema::getASTContext(), clang::ASTContext::getIntTypeForBitwidth(), clang::Expr::getType(), clang::Type::hasSignedIntegerRepresentation(), clang::OMPLoopDirective::HelperExprs::IL, clang::OMPLoopDirective::HelperExprs::Inc, clang::OMPLoopDirective::HelperExprs::Init, clang::OMPLoopDirective::HelperExprs::Inits, clang::DeclContext::isDependentContext(), clang::Expr::isIntegerConstantExpr(), clang::isOpenMPWorksharingDirective(), clang::ActionResult< PtrTy, CompressInvalid >::isUnset(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), clang::OMPLoopDirective::HelperExprs::IterationVarRef, clang::OMPLoopDirective::HelperExprs::LastIteration, clang::OMPLoopDirective::HelperExprs::LB, clang::OMPLoopDirective::HelperExprs::NLB, clang::OMPLoopDirective::HelperExprs::NUB, clang::OMPLoopDirective::HelperExprs::NumIterations, clang::Sema::PerformImplicitConversion(), clang::OMPLoopDirective::HelperExprs::PreCond, clang::Result, clang::OMPLoopDirective::HelperExprs::ST, clang::OMPLoopDirective::HelperExprs::UB, clang::OMPLoopDirective::HelperExprs::Updates, and WidenIterationCount().

Referenced by clang::Sema::ActOnOpenMPForDirective(), clang::Sema::ActOnOpenMPForSimdDirective(), clang::Sema::ActOnOpenMPParallelForDirective(), clang::Sema::ActOnOpenMPParallelForSimdDirective(), and clang::Sema::ActOnOpenMPSimdDirective().

static bool FinishOpenMPLinearClause ( OMPLinearClause Clause,
DeclRefExpr IV,
Expr NumIterations,
Sema SemaRef,
Scope S 
)
static
static bool FitsInto ( unsigned  Bits,
bool  Signed,
Expr E,
Sema SemaRef 
)
static

Check if the given expression E is a constant integer that fits into Bits bits.

Definition at line 3081 of file SemaOpenMP.cpp.

References clang::Sema::Context, clang::Expr::isIntegerConstantExpr(), and clang::Result.

Referenced by CheckOpenMPLoop().

static Expr* GetCollapseNumberExpr ( ArrayRef< OMPClause * >  Clauses)
static
static void ReportOriginalDSA ( Sema SemaRef,
DSAStackTy *  Stack,
const VarDecl VD,
DSAStackTy::DSAVarData  DVar,
bool  IsLoopIterVar = false 
)
static
static ExprResult WidenIterationCount ( unsigned  Bits,
Expr E,
Sema SemaRef 
)
static

Convert integer expression E to make it have at least Bits bits.

Definition at line 3064 of file SemaOpenMP.cpp.

References AttributeLangSupport::C, clang::Sema::Context, clang::ExprError(), clang::Expr::getType(), and clang::Sema::PerformImplicitConversion().

Referenced by CheckOpenMPLoop().