Skip to content

[SYCL][NFC] Fix static code analysis concerns #2789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,9 @@ void KernelObjVisitor::visitRecord(const CXXRecordDecl *Owner, ParentTy &Parent,
const CXXRecordDecl *Wrapper,
QualType RecordTy,
HandlerTys &... Handlers) {
if (RecordTy->getAsRecordDecl()->hasAttr<SYCLRequiresDecompositionAttr>()) {
RecordDecl *RD = RecordTy->getAsRecordDecl();
assert(RD && "should not be null.");
if (RD->hasAttr<SYCLRequiresDecompositionAttr>()) {
// If this container requires decomposition, we have to visit it as
// 'complex', so all handlers are called in this case with the 'complex'
// case.
Expand Down Expand Up @@ -1583,6 +1585,7 @@ class SyclKernelDecompMarker : public SyclKernelFieldHandler {
bool leaveStruct(const CXXRecordDecl *, FieldDecl *, QualType Ty) final {
if (CollectionStack.pop_back_val()) {
RecordDecl *RD = Ty->getAsRecordDecl();
assert(RD && "should not be null.");
if (!RD->hasAttr<SYCLRequiresDecompositionAttr>())
RD->addAttr(SYCLRequiresDecompositionAttr::CreateImplicit(
SemaRef.getASTContext()));
Expand All @@ -1601,6 +1604,7 @@ class SyclKernelDecompMarker : public SyclKernelFieldHandler {
QualType Ty) final {
if (CollectionStack.pop_back_val()) {
RecordDecl *RD = Ty->getAsRecordDecl();
assert(RD && "should not be null.");
if (!RD->hasAttr<SYCLRequiresDecompositionAttr>())
RD->addAttr(SYCLRequiresDecompositionAttr::CreateImplicit(
SemaRef.getASTContext()));
Expand Down