@@ -1752,6 +1752,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1752
1752
const CXXRecordDecl *KernelObj;
1753
1753
llvm::SmallVector<Expr *, 16 > MemberExprBases;
1754
1754
FunctionDecl *KernelCallerFunc;
1755
+ SourceLocation KernelCallerSrcLoc; // KernelCallerFunc source location.
1755
1756
// Contains a count of how many containers we're in. This is used by the
1756
1757
// pointer-struct-wrapping code to ensure that we don't try to wrap
1757
1758
// non-top-level pointers.
@@ -1821,7 +1822,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1821
1822
1822
1823
QualType ParamType = KernelParameter->getOriginalType ();
1823
1824
Expr *DRE = SemaRef.BuildDeclRefExpr (KernelParameter, ParamType, VK_LValue,
1824
- SourceLocation () );
1825
+ KernelCallerSrcLoc );
1825
1826
return DRE;
1826
1827
}
1827
1828
@@ -1833,7 +1834,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1833
1834
1834
1835
QualType ParamType = KernelParameter->getOriginalType ();
1835
1836
Expr *DRE = SemaRef.BuildDeclRefExpr (KernelParameter, ParamType, VK_LValue,
1836
- SourceLocation () );
1837
+ KernelCallerSrcLoc );
1837
1838
1838
1839
// Struct Type kernel arguments are decomposed. The pointer fields are
1839
1840
// then wrapped inside a compiler generated struct. Therefore when
@@ -1846,6 +1847,10 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1846
1847
ParamType = Pointer->getType ();
1847
1848
}
1848
1849
1850
+ DRE =
1851
+ ImplicitCastExpr::Create (SemaRef.Context , ParamType, CK_LValueToRValue,
1852
+ DRE, /* BasePath=*/ nullptr , VK_RValue);
1853
+
1849
1854
if (PointerTy->getPointeeType ().getAddressSpace () !=
1850
1855
ParamType->getPointeeType ().getAddressSpace ())
1851
1856
DRE = ImplicitCastExpr::Create (SemaRef.Context , PointerTy,
@@ -1876,7 +1881,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1876
1881
1877
1882
void addFieldInit (FieldDecl *FD, QualType Ty, MultiExprArg ParamRef) {
1878
1883
InitializationKind InitKind =
1879
- InitializationKind::CreateCopy (SourceLocation (), SourceLocation () );
1884
+ InitializationKind::CreateCopy (KernelCallerSrcLoc, KernelCallerSrcLoc );
1880
1885
addFieldInit (FD, Ty, ParamRef, InitKind);
1881
1886
}
1882
1887
@@ -1913,10 +1918,10 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1913
1918
MemberExpr *buildMemberExpr (Expr *Base, ValueDecl *Member) {
1914
1919
DeclAccessPair MemberDAP = DeclAccessPair::make (Member, AS_none);
1915
1920
MemberExpr *Result = SemaRef.BuildMemberExpr (
1916
- Base, /* IsArrow */ false , SourceLocation () , NestedNameSpecifierLoc (),
1917
- SourceLocation () , Member, MemberDAP,
1921
+ Base, /* IsArrow */ false , KernelCallerSrcLoc , NestedNameSpecifierLoc (),
1922
+ KernelCallerSrcLoc , Member, MemberDAP,
1918
1923
/* HadMultipleCandidates*/ false ,
1919
- DeclarationNameInfo (Member->getDeclName (), SourceLocation () ),
1924
+ DeclarationNameInfo (Member->getDeclName (), KernelCallerSrcLoc ),
1920
1925
Member->getType (), VK_LValue, OK_Ordinary);
1921
1926
return Result;
1922
1927
}
@@ -1944,7 +1949,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1944
1949
for (size_t I = 0 ; I < NumParams; ++I) {
1945
1950
QualType ParamType = KernelParameters[I]->getOriginalType ();
1946
1951
ParamDREs[I] = SemaRef.BuildDeclRefExpr (KernelParameters[I], ParamType,
1947
- VK_LValue, SourceLocation () );
1952
+ VK_LValue, KernelCallerSrcLoc );
1948
1953
}
1949
1954
1950
1955
MemberExpr *MethodME = buildMemberExpr (MemberExprBases.back (), Method);
@@ -1954,12 +1959,12 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1954
1959
ResultTy = ResultTy.getNonLValueExprType (SemaRef.Context );
1955
1960
llvm::SmallVector<Expr *, 4 > ParamStmts;
1956
1961
const auto *Proto = cast<FunctionProtoType>(Method->getType ());
1957
- SemaRef.GatherArgumentsForCall (SourceLocation () , Method, Proto, 0 ,
1962
+ SemaRef.GatherArgumentsForCall (KernelCallerSrcLoc , Method, Proto, 0 ,
1958
1963
ParamDREs, ParamStmts);
1959
1964
// [kernel_obj or wrapper object].accessor.__init(_ValueType*,
1960
1965
// range<int>, range<int>, id<int>)
1961
1966
AddTo.push_back (CXXMemberCallExpr::Create (
1962
- SemaRef.Context , MethodME, ParamStmts, ResultTy, VK, SourceLocation () ,
1967
+ SemaRef.Context , MethodME, ParamStmts, ResultTy, VK, KernelCallerSrcLoc ,
1963
1968
FPOptionsOverride ()));
1964
1969
}
1965
1970
@@ -1981,7 +1986,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
1981
1986
1982
1987
InitListExpr *createInitListExpr (QualType InitTy, uint64_t NumChildInits) {
1983
1988
InitListExpr *ILE = new (SemaRef.getASTContext ()) InitListExpr (
1984
- SemaRef.getASTContext (), SourceLocation () , {}, SourceLocation () );
1989
+ SemaRef.getASTContext (), KernelCallerSrcLoc , {}, KernelCallerSrcLoc );
1985
1990
ILE->reserveInits (SemaRef.getASTContext (), NumChildInits);
1986
1991
ILE->setType (InitTy);
1987
1992
@@ -2007,16 +2012,17 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2007
2012
TypeSourceInfo *TSInfo =
2008
2013
KernelObj->isLambda () ? KernelObj->getLambdaTypeInfo () : nullptr ;
2009
2014
VarDecl *VD = VarDecl::Create (
2010
- Ctx, DC, SourceLocation (), SourceLocation (), KernelObj->getIdentifier (),
2011
- QualType (KernelObj->getTypeForDecl (), 0 ), TSInfo, SC_None);
2015
+ Ctx, DC, KernelObj->getLocation (), KernelObj->getLocation (),
2016
+ KernelObj->getIdentifier (), QualType (KernelObj->getTypeForDecl (), 0 ),
2017
+ TSInfo, SC_None);
2012
2018
2013
2019
return VD;
2014
2020
}
2015
2021
2016
2022
// Default inits the type, then calls the init-method in the body.
2017
2023
bool handleSpecialType (FieldDecl *FD, QualType Ty) {
2018
2024
addFieldInit (FD, Ty, None,
2019
- InitializationKind::CreateDefault (SourceLocation () ));
2025
+ InitializationKind::CreateDefault (KernelCallerSrcLoc ));
2020
2026
2021
2027
addFieldMemberExpr (FD, Ty);
2022
2028
@@ -2030,7 +2036,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2030
2036
2031
2037
bool handleSpecialType (const CXXBaseSpecifier &BS, QualType Ty) {
2032
2038
const auto *RecordDecl = Ty->getAsCXXRecordDecl ();
2033
- addBaseInit (BS, Ty, InitializationKind::CreateDefault (SourceLocation () ));
2039
+ addBaseInit (BS, Ty, InitializationKind::CreateDefault (KernelCallerSrcLoc ));
2034
2040
createSpecialMethodCall (RecordDecl, InitMethodName, BodyStmts);
2035
2041
return true ;
2036
2042
}
@@ -2043,15 +2049,16 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2043
2049
KernelObjClone (createKernelObjClone(S.getASTContext(),
2044
2050
DC.getKernelDecl(), KernelObj)),
2045
2051
VarEntity(InitializedEntity::InitializeVariable(KernelObjClone)),
2046
- KernelObj(KernelObj), KernelCallerFunc(KernelCallerFunc) {
2052
+ KernelObj(KernelObj), KernelCallerFunc(KernelCallerFunc),
2053
+ KernelCallerSrcLoc(KernelCallerFunc->getLocation ()) {
2047
2054
CollectionInitExprs.push_back (createInitListExpr (KernelObj));
2048
2055
markParallelWorkItemCalls ();
2049
2056
2050
2057
Stmt *DS = new (S.Context ) DeclStmt (DeclGroupRef (KernelObjClone),
2051
- SourceLocation (), SourceLocation () );
2058
+ KernelCallerSrcLoc, KernelCallerSrcLoc );
2052
2059
BodyStmts.push_back (DS);
2053
2060
DeclRefExpr *KernelObjCloneRef = DeclRefExpr::Create (
2054
- S.Context , NestedNameSpecifierLoc (), SourceLocation () , KernelObjClone,
2061
+ S.Context , NestedNameSpecifierLoc (), KernelCallerSrcLoc , KernelObjClone,
2055
2062
false , DeclarationNameInfo (), QualType (KernelObj->getTypeForDecl (), 0 ),
2056
2063
VK_LValue);
2057
2064
MemberExprBases.push_back (KernelObjCloneRef);
@@ -2099,7 +2106,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2099
2106
2100
2107
bool handlePointerType (FieldDecl *FD, QualType FieldTy) final {
2101
2108
Expr *PointerRef =
2102
- createPointerParamReferenceExpr (FD-> getType () , StructDepth != 0 );
2109
+ createPointerParamReferenceExpr (FieldTy , StructDepth != 0 );
2103
2110
addFieldInit (FD, FieldTy, PointerRef);
2104
2111
return true ;
2105
2112
}
@@ -2162,7 +2169,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2162
2169
CXXCastPath BasePath;
2163
2170
QualType DerivedTy (RD->getTypeForDecl (), 0 );
2164
2171
QualType BaseTy = BS.getType ();
2165
- SemaRef.CheckDerivedToBaseConversion (DerivedTy, BaseTy, SourceLocation () ,
2172
+ SemaRef.CheckDerivedToBaseConversion (DerivedTy, BaseTy, KernelCallerSrcLoc ,
2166
2173
SourceRange (), &BasePath,
2167
2174
/* IgnoreBaseAccess*/ true );
2168
2175
auto Cast = ImplicitCastExpr::Create (
@@ -2211,11 +2218,11 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
2211
2218
Index, SizeT->isSignedIntegerType ()};
2212
2219
2213
2220
auto IndexLiteral = IntegerLiteral::Create (
2214
- SemaRef.getASTContext (), IndexVal, SizeT, SourceLocation () );
2221
+ SemaRef.getASTContext (), IndexVal, SizeT, KernelCallerSrcLoc );
2215
2222
2216
2223
ExprResult IndexExpr = SemaRef.CreateBuiltinArraySubscriptExpr (
2217
- MemberExprBases.back (), SourceLocation{} , IndexLiteral,
2218
- SourceLocation{} );
2224
+ MemberExprBases.back (), KernelCallerSrcLoc , IndexLiteral,
2225
+ KernelCallerSrcLoc );
2219
2226
2220
2227
assert (!IndexExpr.isInvalid ());
2221
2228
MemberExprBases.push_back (IndexExpr.get ());
0 commit comments