This is an archive of the discontinued LLVM Phabricator instance.

[NFC][CLANG] Fix static analyzer bugs about large copy by values
ClosedPublic

Authored by Manna on Aug 22 2023, 8:44 AM.

Details

Summary

Static Analyzer Tool complains about a large function call parameter which is is passed by value in CGBuiltin.cpp file.

  1. In CodeGenFunction::​EmitSMELdrStr(clang::​SVETypeFlags, llvm::​SmallVectorImpl<llvm::​Value *> &, unsigned int): We are passing parameter TypeFlags of type clang::SVETypeFlags by value.
  1. In CodeGenFunction::​EmitSMEZero(clang::​SVETypeFlags, llvm::​SmallVectorImpl<llvm::​Value *> &, unsigned int): We are passing parameter TypeFlags of type clang::SVETypeFlags by value.
  1. In cCodeGenFunction::​EmitSMEReadWrite(clang::​SVETypeFlags, llvm::​SmallVectorImpl<llvm::​Value *> &, unsigned int): We are passing parameter TypeFlags of type clang::SVETypeFlags by value.
  1. In CodeGenFunction::​EmitSMELd1St1(clang::​SVETypeFlags, llvm::​SmallVectorImpl<llvm::​Value *> &, unsigned int): We are passing parameter TypeFlags of type clang::SVETypeFlags by value.

I see many places in CGBuiltin.cpp file, we are passing parameter TypeFlags of type clang::SVETypeFlags by reference.

clang::SVETypeFlags inherits several other types: https://clang.llvm.org/doxygen/classclang_1_1SVETypeFlags-members.html

This patch passes parameter TypeFlags by reference instead of by value in the function.

Diff Detail

Event Timeline

Manna created this revision.Aug 22 2023, 8:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 8:44 AM
Manna requested review of this revision.Aug 22 2023, 8:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 8:44 AM
sdesmalen accepted this revision.Aug 22 2023, 8:48 AM
sdesmalen added a subscriber: sdesmalen.

It indeed makes sense to pass these by reference.

This revision is now accepted and ready to land.Aug 22 2023, 8:48 AM
Manna added a comment.Aug 22 2023, 8:52 AM

It indeed makes sense to pass these by reference.

Thank you @sdesmalen for reviews!

Manna updated this revision to Diff 552428.Aug 22 2023, 10:41 AM

Fix build errors. I have updated CodeGenFunction.h as well.

tahonermann accepted this revision.Aug 22 2023, 11:25 AM

Looks fine to me!

Looks fine to me!

Thanks @tahonermann for reviews!

Manna added a comment.Aug 23 2023, 7:54 AM

Failure is unrelated to my patch.

This revision was landed with ongoing or failed builds.Aug 23 2023, 7:58 AM
This revision was automatically updated to reflect the committed changes.