Skip to content

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

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 1 commit into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGSYCLRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ bool Util::matchQualifiedTypeName(const CXXRecordDecl *RecTy,
// (namespace) and name.
if (!RecTy)
return false; // only classes/structs supported
const auto *Ctx = dyn_cast<DeclContext>(RecTy);
const auto *Ctx = cast<DeclContext>(RecTy);
StringRef Name = "";

for (const auto &Scope : llvm::reverse(Scopes)) {
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,14 +662,14 @@ static void fixupPrivateMemoryPFWILambdaCaptures(CallInst *PFWICall) {
// now rewrite the captured addresss of a private_memory variables within the
// PFWI lambda object:
for (auto &C : PrivMemCaptures) {
GetElementPtrInst *NewGEP = dyn_cast<GetElementPtrInst>(C.second->clone());
GetElementPtrInst *NewGEP = cast<GetElementPtrInst>(C.second->clone());
NewGEP->insertBefore(PFWICall);
IRBuilder<> Bld(PFWICall->getContext());
Bld.SetInsertPoint(PFWICall);
Value *Val = C.first;
auto ValAS = dyn_cast<PointerType>(Val->getType())->getAddressSpace();
auto PtrAS = dyn_cast<PointerType>(NewGEP->getResultElementType())
->getAddressSpace();
auto ValAS = cast<PointerType>(Val->getType())->getAddressSpace();
auto PtrAS =
cast<PointerType>(NewGEP->getResultElementType())->getAddressSpace();

if (ValAS != PtrAS)
Val = Bld.CreateAddrSpaceCast(Val, NewGEP->getResultElementType());
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {

if (FunctionDecl *Callee = e->getDirectCallee()) {
Callee = Callee->getCanonicalDecl();
assert(Callee && "Device function canonical decl must be available");

// Remember that all SYCL kernel functions have deferred
// instantiation as template functions. It means that
// all functions used by kernel have already been parsed and have
Expand Down Expand Up @@ -254,7 +256,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
}
// Specifically check if the math library function corresponding to this
// builtin is supported for SYCL
unsigned BuiltinID = (Callee ? Callee->getBuiltinID() : 0);
unsigned BuiltinID = Callee->getBuiltinID();
if (BuiltinID && !IsSyclMathFunc(BuiltinID)) {
StringRef Name = SemaRef.Context.BuiltinInfo.getName(BuiltinID);
SemaRef.Diag(e->getExprLoc(), diag::err_builtin_target_unsupported)
Expand Down