This is an archive of the discontinued LLVM Phabricator instance.

[NFC][CLANG] Fix static analyzer codes concerns about large copies by value
AbandonedPublic

Authored by Manna on May 1 2023, 8:17 PM.

Details

Summary

Reported by Static Analyzer Tool:

  1. Inside "Format.cpp" file, in clang::​format::​internal::​reformat(clang::​format::​FormatStyle const &, llvm::​StringRef, llvm::​ArrayRef<clang::​tooling::​Range>, unsigned int, unsigned int, unsigned int, llvm::​StringRef, clang::​format::​FormattingAttemptStatus *)::​[lambda(clang::​format::​Environment const &) (instance 4)]::​operator ()(clang::​format::​Environment const &): A very large function call parameter exceeding the high threshold is passed by value.

pass_by_value: Capturing variable S of type clang::format::FormatStyle (size 800 bytes) by value, which exceeds the high threshold of 512 bytes

This patch removes redundant capturing variable S and uses type clang::format::FormatStyle Expanded instead.

  1. Inside "ClangAttrEmitter.cpp" file, in clang::​GenerateMutualExclusionsChecks(llvm::​Record const &, llvm::​RecordKeeper const &, llvm::​raw_ostream &, llvm::​raw_ostream &, llvm::​raw_ostream &)::​[lambda(llvm::​Record const *) (instance 1)]::​operator ()(llvm::​Record const *): A large function call parameter exceeding the low threshold is passed by value.

pass_by_value: Capturing variable Attr of type llvm::Record const (size 176 bytes) by value, which exceeds the low threshold of 128 bytes.

This patch passes const Record by reference in IsCurAttr lambda capture.

Diff Detail

Event Timeline

Manna created this revision.May 1 2023, 8:17 PM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald Transcript
Manna requested review of this revision.May 1 2023, 8:17 PM
Manna abandoned this revision.May 2 2023, 4:26 AM