This is an archive of the discontinued LLVM Phabricator instance.

[Coverity] Fix explicit null dereferences
ClosedPublic

Authored by akshaykhadse on Apr 21 2023, 3:01 AM.

Details

Summary

This change fixes static code analysis errors

Diff Detail

Event Timeline

akshaykhadse created this revision.Apr 21 2023, 3:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 3:01 AM
akshaykhadse requested review of this revision.Apr 21 2023, 3:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 3:01 AM
skan added inline comments.Apr 21 2023, 8:05 AM
llvm/include/llvm/ADT/SparseSet.h
206

Sparse != nullptr -> Sparse

llvm/include/llvm/CodeGen/PBQP/CostAllocator.h
103

I think it's a UB due to the sequence issue https://en.wikipedia.org/wiki/Sequence_point , right?

llvm/include/llvm/CodeGen/SelectionDAGNodes.h
1138

Why is this function special?

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
1276

MMI != nullptr -> MMI

llvm/lib/CodeGen/ScheduleDAG.cpp
728

Same here

akshaykhadse added inline comments.Apr 21 2023, 8:16 PM
llvm/include/llvm/ADT/SparseSet.h
206

"Sparse != nullptr" makes code more readable. Do you still want me to change this?

llvm/include/llvm/CodeGen/PBQP/CostAllocator.h
103

Yes. That's correct.

llvm/include/llvm/CodeGen/SelectionDAGNodes.h
1138

This is not special. But, Coverity identified that this is where the dereference happens. So, potentially all the functions that call this one will lead to Coverity warning sooner or later.

skan accepted this revision.Apr 21 2023, 9:22 PM

LGTM

This revision is now accepted and ready to land.Apr 21 2023, 9:22 PM
This revision was landed with ongoing or failed builds.Apr 22 2023, 9:07 PM
This revision was automatically updated to reflect the committed changes.

Good morning from the UK,

My apologies but I've had to revert this patch as it caused the following two build bots to begin failing:

https://lab.llvm.org/buildbot/#/builders/216/builds/20322
https://lab.llvm.org/buildbot/#/builders/123/builds/18511

Warmest regards,
Tom W