From c908f3fc99c1c9debdcbf2d9108d5ccb95fa27cf Mon Sep 17 00:00:00 2001 From: Mikhail Lychkov Date: Thu, 20 Feb 2020 01:29:12 +0300 Subject: [PATCH] [SYCL] Fix static code analyzis concerns. Signed-off-by: Mikhail Lychkov --- clang/lib/CodeGen/CGSYCLRuntime.cpp | 2 +- clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp | 8 ++++---- clang/lib/Sema/SemaSYCL.cpp | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/lib/CodeGen/CGSYCLRuntime.cpp b/clang/lib/CodeGen/CGSYCLRuntime.cpp index daafdbe03b9a7..fb3adf4e508cd 100644 --- a/clang/lib/CodeGen/CGSYCLRuntime.cpp +++ b/clang/lib/CodeGen/CGSYCLRuntime.cpp @@ -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(RecTy); + const auto *Ctx = cast(RecTy); StringRef Name = ""; for (const auto &Scope : llvm::reverse(Scopes)) { diff --git a/clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp b/clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp index b43861a4bfd0b..37caf2b741320 100644 --- a/clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp +++ b/clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp @@ -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(C.second->clone()); + GetElementPtrInst *NewGEP = cast(C.second->clone()); NewGEP->insertBefore(PFWICall); IRBuilder<> Bld(PFWICall->getContext()); Bld.SetInsertPoint(PFWICall); Value *Val = C.first; - auto ValAS = dyn_cast(Val->getType())->getAddressSpace(); - auto PtrAS = dyn_cast(NewGEP->getResultElementType()) - ->getAddressSpace(); + auto ValAS = cast(Val->getType())->getAddressSpace(); + auto PtrAS = + cast(NewGEP->getResultElementType())->getAddressSpace(); if (ValAS != PtrAS) Val = Bld.CreateAddrSpaceCast(Val, NewGEP->getResultElementType()); diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index af257347d8823..6e4a593c0b6ff 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -215,6 +215,8 @@ class MarkDeviceFunction : public RecursiveASTVisitor { 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 @@ -254,7 +256,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor { } // 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)