Skip to content

Commit 2675499

Browse files
authored
[SYCL][NFC] Fix static code analysis concerns (#4932)
Found via a static-analysis tool: Pointer may be dereferenced after it was positively checked for NULL Inside GenerateCode() function: if (FD->isInlineBuiltinDeclaration() && Fn) {} ----> Pointer 'Fn' checked for NULL here if (SyclOptReport.HasOptReportInfo(FD)) { llvm::OptimizationRemarkEmitter ORE(Fn); ---> Pointer 'Fn' is dereferenced by passing argument 1 to function "OptimizationRemarkEmitter" This patch checks Pointer 'Fn' inside routine to resolve the bug. Signed-off-by: Soumi Manna [email protected]
1 parent 1704d16 commit 2675499

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
15401540
StartFunction(GD, ResTy, Fn, FnInfo, Args, Loc, BodyRange.getBegin());
15411541

15421542
SyclOptReportHandler &SyclOptReport = CGM.getDiags().getSYCLOptReport();
1543-
if (SyclOptReport.HasOptReportInfo(FD)) {
1543+
if (Fn && SyclOptReport.HasOptReportInfo(FD)) {
15441544
llvm::OptimizationRemarkEmitter ORE(Fn);
15451545
for (auto ORI : llvm::enumerate(SyclOptReport.GetInfo(FD))) {
15461546
llvm::DiagnosticLocation DL =

0 commit comments

Comments
 (0)