This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Initialize member pointers to nullptr.
AbandonedPublic

Authored by schittir on Aug 21 2023, 11:43 PM.

Details

Diff Detail

Event Timeline

schittir created this revision.Aug 21 2023, 11:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 11:43 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
schittir requested review of this revision.Aug 21 2023, 11:43 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 21 2023, 11:43 PM
aaron.ballman added inline comments.Aug 22 2023, 5:10 AM
clang/include/clang/AST/Stmt.h
2606–2607 ↗(On Diff #552230)

I don't think this initialization is necessary. The constructor for ForStmt initializes all of the valid elements: https://github.com/llvm/llvm-project/blob/87c5a3e203ae3643bc13c9a13917b92a657f4358/clang/lib/AST/Stmt.cpp#L1024

The EmptyShell constructor does not initialize anything but that's because it is piecemeal initialized by the AST importer, but all of its fields are also initialized: https://github.com/llvm/llvm-project/blob/87c5a3e203ae3643bc13c9a13917b92a657f4358/clang/lib/Serialization/ASTReaderStmt.cpp#L296

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
934

This is necessary to initialize because emitTargetKernel() has an early return which does not initialize the passed reference to this object.

tahonermann added inline comments.Aug 22 2023, 8:11 AM
clang/include/clang/AST/Stmt.h
2606–2607 ↗(On Diff #552230)

Declarations like this are common in the AST. I'm curious while static analysis flagged this one in particular. Perhaps it identified a path where one or more of the elements don't get initialized? If so, this would be a good find and a fix should be applied to that path.

schittir marked 2 inline comments as done.Aug 22 2023, 8:21 AM
schittir added inline comments.
clang/include/clang/AST/Stmt.h
2606–2607 ↗(On Diff #552230)

I will follow-up with this one more and open a different PR if necessary. Removing this change.

2606–2607 ↗(On Diff #552230)

Thank you for this analysis!

schittir updated this revision to Diff 552380.Aug 22 2023, 8:22 AM

Remove unnecessary initialization.

tahonermann accepted this revision.Aug 22 2023, 8:36 AM

Looks good to me.

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
934

Return is passed to Builder.CreateIsNotNull(). I briefly inspected and it looks like it handles a null argument, so I agree this looks like the right fix.

This revision is now accepted and ready to land.Aug 22 2023, 8:36 AM
Manna added a subscriber: Manna.Aug 22 2023, 12:02 PM

This has already been addressed by https://reviews.llvm.org/D157989

schittir abandoned this revision.Aug 22 2023, 12:45 PM

This has already been addressed by https://reviews.llvm.org/D157989

Thank you for letting me know. Abandoning this change.