Skip to content

Commit 91da13e

Browse files
authored
[SYCL][NFC] Fix potential null-pointer access (#2197)
Signed-off-by: Premanand M Rao <premanand.m.rao@intel.com>
1 parent 5c91609 commit 91da13e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,13 +3887,13 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
38873887
}
38883888

38893889
if (LangOpts.SYCLIsDevice) {
3890+
if (!D)
3891+
return LangAS::opencl_global;
38903892
auto *Scope = D->getAttr<SYCLScopeAttr>();
3891-
38923893
if (Scope && Scope->isWorkGroup())
38933894
return LangAS::opencl_local;
3894-
if (!D || D->getType().getAddressSpace() == LangAS::Default) {
3895+
if (D->getType().getAddressSpace() == LangAS::Default)
38953896
return LangAS::opencl_global;
3896-
}
38973897
}
38983898

38993899
if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {

0 commit comments

Comments
 (0)