Skip to content

Commit c908f3f

Browse files
committed
[SYCL] Fix static code analyzis concerns.
Signed-off-by: Mikhail Lychkov <[email protected]>
1 parent 65da01b commit c908f3f

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

clang/lib/CodeGen/CGSYCLRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool Util::matchQualifiedTypeName(const CXXRecordDecl *RecTy,
104104
// (namespace) and name.
105105
if (!RecTy)
106106
return false; // only classes/structs supported
107-
const auto *Ctx = dyn_cast<DeclContext>(RecTy);
107+
const auto *Ctx = cast<DeclContext>(RecTy);
108108
StringRef Name = "";
109109

110110
for (const auto &Scope : llvm::reverse(Scopes)) {

clang/lib/CodeGen/SYCLLowerIR/LowerWGScope.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,14 +662,14 @@ static void fixupPrivateMemoryPFWILambdaCaptures(CallInst *PFWICall) {
662662
// now rewrite the captured addresss of a private_memory variables within the
663663
// PFWI lambda object:
664664
for (auto &C : PrivMemCaptures) {
665-
GetElementPtrInst *NewGEP = dyn_cast<GetElementPtrInst>(C.second->clone());
665+
GetElementPtrInst *NewGEP = cast<GetElementPtrInst>(C.second->clone());
666666
NewGEP->insertBefore(PFWICall);
667667
IRBuilder<> Bld(PFWICall->getContext());
668668
Bld.SetInsertPoint(PFWICall);
669669
Value *Val = C.first;
670-
auto ValAS = dyn_cast<PointerType>(Val->getType())->getAddressSpace();
671-
auto PtrAS = dyn_cast<PointerType>(NewGEP->getResultElementType())
672-
->getAddressSpace();
670+
auto ValAS = cast<PointerType>(Val->getType())->getAddressSpace();
671+
auto PtrAS =
672+
cast<PointerType>(NewGEP->getResultElementType())->getAddressSpace();
673673

674674
if (ValAS != PtrAS)
675675
Val = Bld.CreateAddrSpaceCast(Val, NewGEP->getResultElementType());

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
215215

216216
if (FunctionDecl *Callee = e->getDirectCallee()) {
217217
Callee = Callee->getCanonicalDecl();
218+
assert(Callee && "Device function canonical decl must be available");
219+
218220
// Remember that all SYCL kernel functions have deferred
219221
// instantiation as template functions. It means that
220222
// all functions used by kernel have already been parsed and have
@@ -254,7 +256,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
254256
}
255257
// Specifically check if the math library function corresponding to this
256258
// builtin is supported for SYCL
257-
unsigned BuiltinID = (Callee ? Callee->getBuiltinID() : 0);
259+
unsigned BuiltinID = Callee->getBuiltinID();
258260
if (BuiltinID && !IsSyclMathFunc(BuiltinID)) {
259261
StringRef Name = SemaRef.Context.BuiltinInfo.getName(BuiltinID);
260262
SemaRef.Diag(e->getExprLoc(), diag::err_builtin_target_unsupported)

0 commit comments

Comments
 (0)