}
QualType Type = D->getType().getNonReferenceType().getCanonicalType();
- bool IsConstant = Type.isConstant(SemaRef.getASTContext());
- while (Type->isArrayType()) {
- QualType ElemType = cast<ArrayType>(Type.getTypePtr())->getElementType();
- Type = ElemType.getNonReferenceType().getCanonicalType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(D)) {
+ Type = PVD->getOriginalType().getNonReferenceType().getCanonicalType();
}
+ bool IsConstant = Type.isConstant(SemaRef.getASTContext());
+ Type = SemaRef.getASTContext().getBaseElementType(Type);
// OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
// in a Construct, C/C++, predetermined, p.6]
// Variables with const qualified type having no mutable member are
continue;
}
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(DE)->getDecl());
+ QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
auto DVar = DSAStack->getTopDSA(VD, false);
if (DVar.CKind == OMPC_lastprivate) {
// Generate helper private variable and initialize it with the
// variable is not added to IdResolver, so the code in the OpenMP
// region uses original variable for proper diagnostics.
auto *VDPrivate =
- buildVarDecl(*this, DE->getExprLoc(),
- VD->getType().getUnqualifiedType(), VD->getName());
+ buildVarDecl(*this, DE->getExprLoc(), Type.getUnqualifiedType(),
+ VD->getName());
ActOnUninitializedDecl(VDPrivate, /*TypeMayContainAuto=*/false);
if (VDPrivate->isInvalidDecl())
continue;
VarDecl *VD = cast<VarDecl>(D);
QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
if (Type->isDependentType() || Type->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);
continue;
}
- // OpenMP [2.9.3.3, Restrictions, C/C++, p.1]
- // A variable of class type (or array thereof) that appears in a private
- // clause requires an accessible, unambiguous default constructor for the
- // class type.
- while (Type->isArrayType()) {
- Type = cast<ArrayType>(Type.getTypePtr())->getElementType();
- }
-
// OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables Referenced
// in a Construct]
// Variables with the predetermined data-sharing attributes may not be
continue;
}
+ // OpenMP [2.9.3.3, Restrictions, C/C++, p.1]
+ // A variable of class type (or array thereof) that appears in a private
+ // clause requires an accessible, unambiguous default constructor for the
+ // class type.
// Generate helper private variable and initialize it with the default
// value. The address of the original variable is replaced by the address of
// the new private variable in CodeGen. This new variable is not added to
// IdResolver, so the code in the OpenMP region uses original variable for
// proper diagnostics.
- auto VDPrivate =
- buildVarDecl(*this, DE->getExprLoc(),
- VD->getType().getUnqualifiedType(), VD->getName());
+ Type = Type.getUnqualifiedType();
+ auto VDPrivate = buildVarDecl(*this, DE->getExprLoc(), Type, VD->getName());
ActOnUninitializedDecl(VDPrivate, /*TypeMayContainAuto=*/false);
if (VDPrivate->isInvalidDecl())
continue;
- auto VDPrivateRefExpr =
- buildDeclRefExpr(*this, VDPrivate, DE->getType(), DE->getExprLoc());
+ auto VDPrivateRefExpr = buildDeclRefExpr(
+ *this, VDPrivate, DE->getType().getUnqualifiedType(), DE->getExprLoc());
DSAStack->addDSA(VD, DE, OMPC_private);
Vars.push_back(DE);
VarDecl *VD = cast<VarDecl>(D);
QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
if (Type->isDependentType() || Type->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);
// A variable of class type (or array thereof) that appears in a private
// clause requires an accessible, unambiguous copy constructor for the
// class type.
- Type = Context.getBaseElementType(Type).getNonReferenceType();
+ auto ElemType = Context.getBaseElementType(Type).getNonReferenceType();
// If an implicit firstprivate variable found it was checked already.
if (!IsImplicitClause) {
DSAStackTy::DSAVarData DVar = DSAStack->getTopDSA(VD, false);
- Type = Type.getNonReferenceType().getCanonicalType();
- bool IsConstant = Type.isConstant(Context);
- Type = Context.getBaseElementType(Type);
+ bool IsConstant = ElemType.isConstant(Context);
// OpenMP [2.4.13, Data-sharing Attribute Clauses]
// A list item that specifies a given variable may not appear in more
// than one clause on the same directive, except that a variable may be
}
}
- auto VDPrivate = buildVarDecl(
- *this, ELoc, VD->getType().getUnqualifiedType(), VD->getName());
+ Type = Type.getUnqualifiedType();
+ auto VDPrivate = buildVarDecl(*this, ELoc, Type, VD->getName());
// Generate helper private variable and initialize it with the value of the
// original variable. The address of the original variable is replaced by
// the address of the new private variable in the CodeGen. This new variable
Expr *VDInitRefExpr = nullptr;
// For arrays generate initializer for single element and replace it by the
// original array element in CodeGen.
- if (DE->getType()->isArrayType()) {
- auto VDInit = buildVarDecl(*this, DE->getExprLoc(), Type, VD->getName());
- VDInitRefExpr = buildDeclRefExpr(*this, VDInit, Type, ELoc);
+ if (Type->isArrayType()) {
+ auto VDInit =
+ buildVarDecl(*this, DE->getExprLoc(), ElemType, VD->getName());
+ VDInitRefExpr = buildDeclRefExpr(*this, VDInit, ElemType, ELoc);
auto Init = DefaultLvalueConversion(VDInitRefExpr).get();
- auto *VDInitTemp =
- buildVarDecl(*this, DE->getLocStart(), Type.getUnqualifiedType(),
- ".firstprivate.temp");
+ ElemType = ElemType.getUnqualifiedType();
+ auto *VDInitTemp = buildVarDecl(*this, DE->getLocStart(), ElemType,
+ ".firstprivate.temp");
InitializedEntity Entity =
InitializedEntity::InitializeVariable(VDInitTemp);
InitializationKind Kind = InitializationKind::CreateCopy(ELoc, ELoc);
} else {
auto *VDInit =
buildVarDecl(*this, DE->getLocStart(), Type, ".firstprivate.temp");
- VDInitRefExpr = buildDeclRefExpr(*this, VDInit, Type, DE->getExprLoc());
+ VDInitRefExpr =
+ buildDeclRefExpr(*this, VDInit, DE->getType(), DE->getExprLoc());
AddInitializerToDecl(VDPrivate,
DefaultLvalueConversion(VDInitRefExpr).get(),
/*DirectInit=*/false, /*TypeMayContainAuto=*/false);
VarDecl *VD = cast<VarDecl>(D);
QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
if (Type->isDependentType() || Type->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);
VarDecl *VD = cast<VarDecl>(D);
QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
if (Type->isDependentType() || Type->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);
auto D = DE->getDecl();
auto VD = cast<VarDecl>(D);
auto Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
// OpenMP [2.9.3.3, Restrictions, C/C++, p.3]
// A variable that appears in a private clause must not have an incomplete
// type or a reference type.
}
QualType QType = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ QType = PVD->getOriginalType();
+ }
if (QType->isDependentType() || QType->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);
}
// Build var to save initial value.
- VarDecl *Init = buildVarDecl(*this, ELoc, DE->getType(), ".linear.start");
+ VarDecl *Init = buildVarDecl(*this, ELoc, QType, ".linear.start");
AddInitializerToDecl(Init, DefaultLvalueConversion(DE).get(),
/*DirectInit*/ false, /*TypeMayContainAuto*/ false);
- auto InitRef =
- buildDeclRefExpr(*this, Init, DE->getType(), DE->getExprLoc());
+ auto InitRef = buildDeclRefExpr(
+ *this, Init, DE->getType().getUnqualifiedType(), DE->getExprLoc());
DSAStack->addDSA(VD, DE, OMPC_linear);
Vars.push_back(DE);
Inits.push_back(InitRef);
// Build privatized reference to the current linear var.
auto DE = cast<DeclRefExpr>(RefExpr);
auto PrivateRef =
- buildDeclRefExpr(SemaRef, cast<VarDecl>(DE->getDecl()), DE->getType(),
- DE->getExprLoc(), /*RefersToCapture=*/true);
+ buildDeclRefExpr(SemaRef, cast<VarDecl>(DE->getDecl()),
+ DE->getType().getUnqualifiedType(), DE->getExprLoc(),
+ /*RefersToCapture=*/true);
// Build update: Var = InitExpr + IV * Step
ExprResult Update =
// OpenMP [2.8.1, simd construct, Restrictions]
// The type of list items appearing in the aligned clause must be
// array, pointer, reference to array, or reference to pointer.
- QualType QType = DE->getType()
- .getNonReferenceType()
- .getUnqualifiedType()
- .getCanonicalType();
+ QualType QType = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ QType = PVD->getOriginalType();
+ }
+ QType = QType.getNonReferenceType().getUnqualifiedType().getCanonicalType();
const Type *Ty = QType.getTypePtrOrNull();
if (!Ty || (!Ty->isDependentType() && !Ty->isArrayType() &&
!Ty->isPointerType())) {
VarDecl *VD = cast<VarDecl>(D);
QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
if (Type->isDependentType() || Type->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);
// A variable of class type (or array thereof) that appears in a
// copyin clause requires an accessible, unambiguous copy assignment
// operator for the class type.
- Type = Context.getBaseElementType(Type).getNonReferenceType();
+ auto ElemType = Context.getBaseElementType(Type).getNonReferenceType();
auto *SrcVD = buildVarDecl(*this, DE->getLocStart(),
- Type.getUnqualifiedType(), ".copyin.src");
+ ElemType.getUnqualifiedType(), ".copyin.src");
auto *PseudoSrcExpr = buildDeclRefExpr(
- *this, SrcVD, Type.getUnqualifiedType(), DE->getExprLoc());
- auto *DstVD = buildVarDecl(*this, DE->getLocStart(), Type, ".copyin.dst");
+ *this, SrcVD, ElemType.getUnqualifiedType(), DE->getExprLoc());
+ auto *DstVD =
+ buildVarDecl(*this, DE->getLocStart(), ElemType, ".copyin.dst");
auto *PseudoDstExpr =
- buildDeclRefExpr(*this, DstVD, Type, DE->getExprLoc());
+ buildDeclRefExpr(*this, DstVD, ElemType, DE->getExprLoc());
// For arrays generate assignment operation for single element and replace
// it by the original array element in CodeGen.
auto AssignmentOp = BuildBinOp(/*S=*/nullptr, DE->getExprLoc(), BO_Assign,
VarDecl *VD = cast<VarDecl>(D);
QualType Type = VD->getType();
+ if (auto *PVD = dyn_cast<ParmVarDecl>(VD)) {
+ Type = PVD->getOriginalType();
+ }
if (Type->isDependentType() || Type->isInstantiationDependentType()) {
// It will be analyzed later.
Vars.push_back(DE);