This is an archive of the discontinued LLVM Phabricator instance.

[NFC] ][CLANG] Fix static code analyzer concerns
ClosedPublic

Authored by Manna on Apr 28 2023, 9:44 AM.

Details

Summary

Reported by Coverity:

  1. Inside "ASTReader.cpp" file, in clang::​ASTReader::​FindExternalLexicalDecls(clang::​DeclContext const *, llvm::​function_ref<bool (clang::​Decl::​Kind)>, llvm::​SmallVectorImpl<clang::​Decl *> &): Using the auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an object of type pair.

  1. Inside "ASTReader.cpp" file, in clang::​ASTReader::​ReadAST(llvm::​StringRef, clang::​serialization::​ModuleKind, clang::​SourceLocation, unsigned int, llvm::​SmallVectorImpl<clang::​ASTReader::​ImportedSubmodule> *): Using the auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an object of type DenseMapPair.

  1. Inside "CGOpenMPRuntimeGPU.cpp" file, in clang::​CodeGen::​CGOpenMPRuntimeGPU::​emitGenericVarsEpilog(clang::​CodeGen::​CodeGenFunction &, bool): Using the auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an object of type pair.

  1. In clang::​ASTWriter::​WriteHeaderSearch(clang::​HeaderSearch const &): Using the auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an object of type UnresolvedHeaderDirective.

Diff Detail

Event Timeline

Manna created this revision.Apr 28 2023, 9:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2023, 9:44 AM
Manna requested review of this revision.Apr 28 2023, 9:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
Manna edited the summary of this revision. (Show Details)Apr 28 2023, 9:45 AM
Manna updated this revision to Diff 517964.Apr 28 2023, 9:47 AM
Manna added inline comments.Apr 28 2023, 10:29 AM
clang/lib/Serialization/ASTReader.cpp
0–1

Here Object of type is DenseMapPair. SelectorGeneration returns llvm::DenseMap<Selector, Unsigned>' in ASTReader.h' file.

clang/lib/Serialization/ASTWriter.cpp
0–1

Object of type KnownHeader returns ArrayRef<ModuleMap::KnownHeader> in ASTWriter.cpp file.

0–1

This returns SmallVector<UnresolvedHeaderDirective, 1> in `Module.h' file

Manna added inline comments.Apr 28 2023, 10:33 AM
clang/lib/Serialization/ASTReader.cpp
0–1

This returns std::vector<std::pair<ModuleFile*, LexicalContents> in 'ASTReader.h` file

Manna updated this revision to Diff 518347.Apr 30 2023, 12:51 PM
Manna edited the summary of this revision. (Show Details)
Manna abandoned this revision.Apr 30 2023, 12:53 PM
Manna updated this revision to Diff 518373.Apr 30 2023, 5:27 PM
Manna updated this revision to Diff 518375.Apr 30 2023, 6:03 PM
tahonermann accepted this revision.May 5 2023, 1:48 PM

These changes look good to me and I agree with not making a change for the KnownHeaders case.

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
0–1

EscapedVariableLengthDeclsAddrs is a llvm::SmallVector; this looks like a good change.

clang/lib/Serialization/ASTReader.cpp
0–1

Yes, looks like a good change.

0–1

Yes, this looks like a good change.

clang/lib/Serialization/ASTWriter.cpp
0–1

Yes, looks like a good change.

This revision is now accepted and ready to land.May 5 2023, 1:48 PM
Manna added a comment.May 5 2023, 1:51 PM

These changes look good to me and I agree with not making a change for the KnownHeaders case.

I agree with not making a change for the KnownHeaders case.

Yup. I closed them as a false positive.

Thanks @tahonermann for reviews!

This revision was automatically updated to reflect the committed changes.