New Defects reported by Coverity Scan for llvm

Hi,

Please find the latest report on new defect(s) introduced to llvm found with Coverity Scan.

13 new defect(s) introduced to llvm found with Coverity Scan.
25 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 13 of 13 defect(s)

** CID 1506530: Performance inefficiencies (AUTO_CAUSES_COPY)
/flang/lib/Semantics/tools.cpp: 772 in Fortran::semantics::HasImpureFinal(const Fortran::semantics::DerivedTypeSpec &)()


*** CID 1506530: Performance inefficiencies (AUTO_CAUSES_COPY)
/flang/lib/Semantics/tools.cpp: 772 in Fortran::semantics::HasImpureFinal(const Fortran::semantics::DerivedTypeSpec &)()
766 })}};
767 inProgress->erase(iterator);
768 return result;
769 }
770
771 bool HasImpureFinal(const DerivedTypeSpec &derived) {

CID 1506530:  Performance inefficiencies  (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type Reference.

772 for (auto ref : FinalsForDerivedTypeInstantiation(derived)) {
773 if (!IsPureProcedure(*ref)) {
774 return true;
775 }
776 }
777 return false;

** CID 1506529: Resource leaks (RESOURCE_LEAK)
/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp: 113 in lldb_private::wasm::SymbolVendorWasm::CreateInstance(const std::shared_ptr<lldb_private::Module> &, lldb_private::Stream *)()


*** CID 1506529: Resource leaks (RESOURCE_LEAK)
/lldb/source/Plugins/SymbolVendor/wasm/SymbolVendorWasm.cpp: 113 in lldb_private::wasm::SymbolVendorWasm::CreateInstance(const std::shared_ptr<lldb_private::Module> &, lldb_private::Stream *)()
107 // Get the module unified section list and add our debug sections to
108 // that.
109 SectionList *module_section_list = module_sp->GetSectionList();
110 SectionList *objfile_section_list = sym_objfile_sp->GetSectionList();
111
112 if (!module_section_list || !objfile_section_list)

CID 1506529:  Resource leaks  (RESOURCE_LEAK)
Variable "symbol_vendor" going out of scope leaks the storage it points to.

113 return nullptr;
114
115 static const SectionType g_sections = {
116 eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAddr,
117 eSectionTypeDWARFDebugAranges, eSectionTypeDWARFDebugCuIndex,
118 eSectionTypeDWARFDebugFrame, eSectionTypeDWARFDebugInfo,

** CID 1506528: Uninitialized variables (UNINIT)
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp: 141 in extractConvResultSlices(mlir::RewriterBase &, mlir::Location, mlir::Value, long, long, long, long, bool)()


*** CID 1506528: Uninitialized variables (UNINIT)
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp: 141 in extractConvResultSlices(mlir::RewriterBase &, mlir::Location, mlir::Value, long, long, long, long, bool)()
135 SmallVector<int64_t> strides{1, 1, 1};
136 for (int64_t w = 0; w < wSize; w += wSizeStep) {
137 result.push_back(rewriter.createvector::ExtractStridedSliceOp(
138 loc, res, /offsets=/ArrayRef<int64_t>{0, w, 0}, sizes, strides));
139 }
140 }

CID 1506528:  Uninitialized variables  (UNINIT)
Using uninitialized value "result". Field "result.InlineElts" is uninitialized.

141 return result;
142 }
143
144 /// Helper function to insert the computed result slices.
145 static Value insertConvResultSlices(RewriterBase &rewriter, Location loc,
146 Value res, int64_t wSize, int64_t wSizeStep,

** CID 1506527: Performance inefficiencies (AUTO_CAUSES_COPY)
/flang/lib/Semantics/definable.cpp: 231 in Fortran::semantics::WhyNotDefinable(Fortran::parser::CharBlock, const Fortran::semantics::Scope &, Fortran::common::EnumSet<Fortran::semantics::DefinabilityFlag, (unsigned long)4>, const Fortran::evaluate::ExprFortran::evaluate::SomeType &)()


*** CID 1506527: Performance inefficiencies (AUTO_CAUSES_COPY)
/flang/lib/Semantics/definable.cpp: 231 in Fortran::semantics::WhyNotDefinable(Fortran::parser::CharBlock, const Fortran::semantics::Scope &, Fortran::common::EnumSet<Fortran::semantics::DefinabilityFlag, (unsigned long)4>, const Fortran::evaluate::ExprFortran::evaluate::SomeType &)()
225 // dummy argument, there’s no way to call it.
226 int rank{expr.Rank()};
227 const DerivedTypeSpec *spec{&type->GetDerivedTypeSpec()};
228 while (spec) {
229 bool anyElemental{false};
230 const Symbol *anyRankMatch{nullptr};

CID 1506527:  Performance inefficiencies  (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type Reference.

231 for (auto ref : FinalsForDerivedTypeInstantiation(*spec)) {
232 const Symbol &ultimate{ref->GetUltimate()};
233 anyElemental |= ultimate.attrs().test(Attr::ELEMENTAL);
234 if (const auto *subp{ultimate.detailsIf()}) {
235 if (!subp->dummyArgs().empty()) {
236 if (const Symbol * arg{subp->dummyArgs()[0]}) {

** CID 1506526: Performance inefficiencies (AUTO_CAUSES_COPY)
/flang/lib/Semantics/check-omp-structure.cpp: 2041 in Fortran::semantics::OmpStructureChecker::CheckSharedBindingInOuterContext(const Fortran::parser::OmpObjectList &)()


*** CID 1506526: Performance inefficiencies (AUTO_CAUSES_COPY)
/flang/lib/Semantics/check-omp-structure.cpp: 2041 in Fortran::semantics::OmpStructureChecker::CheckSharedBindingInOuterContext(const Fortran::parser::OmpObjectList &)()
2035 void OmpStructureChecker::CheckSharedBindingInOuterContext(
2036 const parser::OmpObjectList &redObjectList) {
2037 // TODO: Verify the assumption here that the immediately enclosing region is
2038 // the parallel region to which the worksharing construct having reduction
2039 // binds to.
2040 if (auto *enclosingContext{GetEnclosingDirContext()}) {

CID 1506526:  Performance inefficiencies  (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type pair.

2041 for (auto it : enclosingContext->clauseInfo) {
2042 llvmOmpClause type = it.first;
2043 const auto *clause = it.second;
2044 if (llvm::omp::privateReductionSet.test(type)) {
2045 if (const auto *objList{GetOmpObjectList(*clause)}) {
2046 for (const auto &ompObject : objList->v) {

** CID 1506525: Control flow issues (DEADCODE)
/build-llvm/tools/clang/stage2-bins/tools/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.cpp.inc: 2292 in mlir::LLVM::AllocaOp::setInalloca(bool)()


*** CID 1506525: Control flow issues (DEADCODE)
/build-llvm/tools/clang/stage2-bins/tools/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.cpp.inc: 2292 in mlir::LLVM::AllocaOp::setInalloca(bool)()
2286 void AllocaOp::setInallocaAttr(::mlir::UnitAttr attr) {
2287 (*this)->setAttr(getInallocaAttrName(), attr);
2288 }
2289
2290 void AllocaOp::setInalloca(bool attrValue) {
2291 if (attrValue)

CID 1506525:  Control flow issues  (DEADCODE)
Execution cannot reach this statement: "<temporary>.UnitAttr(NULL);".

2292 return (*this)->setAttr(getInallocaAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr));
2293 (*this)->removeAttr(getInallocaAttrName());
2294 }
2295
2296 ::mlir::Attribute AllocaOp::removeAlignmentAttr() {
2297 return (*this)->removeAttr(getAlignmentAttrName());

** CID 1506524: Uninitialized variables (UNINIT)
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp: 98 in extractConvInputSlices(mlir::RewriterBase &, mlir::Location, mlir::Value, long, long, long, long, int, int, long, bool)()


*** CID 1506524: Uninitialized variables (UNINIT)
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp: 98 in extractConvInputSlices(mlir::RewriterBase &, mlir::Location, mlir::Value, long, long, long, long, int, int, long, bool)()
92 loc, input,
93 /offsets=/ArrayRef<int64_t>{0, w * strideW + kw * dilationW, 0},
94 sizes, strides));
95 }
96 }
97 }

CID 1506524:  Uninitialized variables  (UNINIT)
Using uninitialized value "result". Field "result.InlineElts" is uninitialized.

98 return result;
99 }
100
101 /// Helper function to extract the filter slices after filter is unrolled along
102 /// kw.
103 static SmallVector extractConvFilterSlices(RewriterBase &rewriter,

** CID 1506523: Performance inefficiencies (AUTO_CAUSES_COPY)
/mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp: 122 in mlir::sparse_tensor::LoopEmitter::genSliceLegitPredicate(mlir::OpBuilder &, mlir::Location, mlir::Value, unsigned int, unsigned int)()


*** CID 1506523: Performance inefficiencies (AUTO_CAUSES_COPY)
/mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp: 122 in mlir::sparse_tensor::LoopEmitter::genSliceLegitPredicate(mlir::OpBuilder &, mlir::Location, mlir::Value, unsigned int, unsigned int)()
116 constantIndex(builder, loc, 0));
117 conds.push_back(fitStride);
118 }
119
120 // Must meet all condition to be a valid coordinate in slice.
121 auto pred = conds.front();

CID 1506523:  Performance inefficiencies  (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type Value.

122 for (auto cond : ValueRange(conds).drop_front())
123 pred = builder.createarith::AndIOp(loc, pred, cond);
124
125 return {transformedCrd.first, pred};
126 }
127

** CID 1506522: Resource leaks (RESOURCE_LEAK)
/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp: 115 in SymbolVendorELF::CreateInstance(const std::shared_ptr<lldb_private::Module> &, lldb_private::Stream *)()


*** CID 1506522: Resource leaks (RESOURCE_LEAK)
/lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp: 115 in SymbolVendorELF::CreateInstance(const std::shared_ptr<lldb_private::Module> &, lldb_private::Stream *)()
109 // Get the module unified section list and add our debug sections to
110 // that.
111 SectionList *module_section_list = module_sp->GetSectionList();
112 SectionList *objfile_section_list = dsym_objfile_sp->GetSectionList();
113
114 if (!module_section_list || !objfile_section_list)

CID 1506522:  Resource leaks  (RESOURCE_LEAK)
Variable "symbol_vendor" going out of scope leaks the storage it points to.

115 return nullptr;
116
117 static const SectionType g_sections = {
118 eSectionTypeDWARFDebugAbbrev, eSectionTypeDWARFDebugAddr,
119 eSectionTypeDWARFDebugAranges, eSectionTypeDWARFDebugCuIndex,
120 eSectionTypeDWARFDebugFrame, eSectionTypeDWARFDebugInfo,

** CID 1506521: Performance inefficiencies (AUTO_CAUSES_COPY)
/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp: 3435 in mlir::tensor::PackOp::requirePaddingValue(llvm::ArrayRef, llvm::ArrayRef, llvm::ArrayRefmlir::OpFoldResult)()


*** CID 1506521: Performance inefficiencies (AUTO_CAUSES_COPY)
/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp: 3435 in mlir::tensor::PackOp::requirePaddingValue(llvm::ArrayRef, llvm::ArrayRef, llvm::ArrayRefmlir::OpFoldResult)()
3429 return getStaticTilesImpl(*this);
3430 }
3431
3432 bool PackOp::requirePaddingValue(ArrayRef<int64_t> inputShape,
3433 ArrayRef<int64_t> innerDimsPos,
3434 ArrayRef innerTiles) {

CID 1506521:  Performance inefficiencies  (AUTO_CAUSES_COPY)
Using the "auto" keyword without an "&" causes the copy of an object of type tuple.

3435 for (auto [pos, tileSize] : llvm::zip_equal(innerDimsPos, innerTiles)) {
3436 if (ShapedType::isDynamic(inputShape[pos]))
3437 continue;
3438 std::optional<int64_t> constantTile = getConstantIntValue(tileSize);
3439 if (!constantTile)
3440 continue;

** CID 1506520: Uninitialized variables (UNINIT)
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp: 113 in extractConvFilterSlices(mlir::RewriterBase &, mlir::Location, mlir::Value, long)()


*** CID 1506520: Uninitialized variables (UNINIT)
/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp: 113 in extractConvFilterSlices(mlir::RewriterBase &, mlir::Location, mlir::Value, long)()
107 // Extract rhs slice of size [{c, f} for channeled convolutions and {1} for
108 // non-chanelled convolution] @ [kw].
109 for (int64_t kw = 0; kw < kwSize; ++kw) {
110 result.push_back(rewriter.createvector::ExtractOp(
111 loc, filter, /offsets=/ArrayRef<int64_t>{kw}));
112 }

CID 1506520:  Uninitialized variables  (UNINIT)
Using uninitialized value "result". Field "result.InlineElts" is uninitialized.

113 return result;
114 }
115
116 /// Helper function to extract the result slices after filter is unrolled along
117 /// kw.
118 static SmallVector

** CID 1506519: Performance inefficiencies (PASS_BY_VALUE)
/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp: 580 in clang::tooling::dependencies::ModuleDepCollector::ModuleDepCollector(std::unique_ptr<clang::DependencyOutputOptions, std::default_deleteclang::DependencyOutputOptions>, clang::CompilerInstance &, clang::tooling::dependencies::DependencyConsumer &, clang::tooling::dependencies::DependencyActionController &, clang::CompilerInvocation, bool, bool, bool)()


*** CID 1506519: Performance inefficiencies (PASS_BY_VALUE)
/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp: 580 in clang::tooling::dependencies::ModuleDepCollector::ModuleDepCollector(std::unique_ptr<clang::DependencyOutputOptions, std::default_deleteclang::DependencyOutputOptions>, clang::CompilerInstance &, clang::tooling::dependencies::DependencyConsumer &, clang::tooling::dependencies::DependencyActionController &, clang::CompilerInvocation, bool, bool, bool)()
574 }
575 }
576
577 ModuleDepCollector::ModuleDepCollector(
578 std::unique_ptr Opts,
579 CompilerInstance &ScanInstance, DependencyConsumer &C,

CID 1506519:  Performance inefficiencies  (PASS_BY_VALUE)
Passing parameter OriginalCI of type "clang::CompilerInvocation" (size 3296 bytes) by value, which exceeds the high threshold of 512 bytes.

580 DependencyActionController &Controller, CompilerInvocation OriginalCI,
581 bool OptimizeArgs, bool EagerLoadModules, bool IsStdModuleP1689Format)
582 : ScanInstance(ScanInstance), Consumer(C), Controller(Controller),
583 Opts(std::move(Opts)), OriginalInvocation(std::move(OriginalCI)),
584 OptimizeArgs(OptimizeArgs), EagerLoadModules(EagerLoadModules),
585 IsStdModuleP1689Format(IsStdModuleP1689Format) {}

** CID 1506518: Uninitialized variables (UNINIT)
/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp: 422 in clang::tooling::dependencies::DependencyScanningWorker::computeDependencies(llvm::StringRef, const std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator>, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator>>> &, clang::tooling::dependencies::DependencyConsumer &, clang::tooling::dependencies::DependencyActionController &, clang::DiagnosticConsumer &, std::optionalllvm::StringRef)()


*** CID 1506518: Uninitialized variables (UNINIT)
/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp: 422 in clang::tooling::dependencies::DependencyScanningWorker::computeDependencies(llvm::StringRef, const std::vector<std::__cxx11::basic_string<char, std::char_traits, std::allocator>, std::allocator<std::__cxx11::basic_string<char, std::char_traits, std::allocator>>> &, clang::tooling::dependencies::DependencyConsumer &, clang::tooling::dependencies::DependencyActionController &, clang::DiagnosticConsumer &, std::optionalllvm::StringRef)()
416 llvm::sys::fs::createUniquePath(*ModuleName + “-%%%%%%%%.input”,
417 FakeInputPath,
418 /MakeAbsolute=/false);
419 InMemoryFS->addFile(FakeInputPath, 0, llvm::MemoryBuffer::getMemBuffer(“”));
420
421 ModifiedCommandLine = CommandLine;

CID 1506518:  Uninitialized variables  (UNINIT)
Using uninitialized value "FakeInputPath". Field "FakeInputPath.InlineElts" is uninitialized when calling "emplace_back". [Note: The source code implementation of the function has been overridden by a builtin model.]

422 ModifiedCommandLine->emplace_back(FakeInputPath);
423 }
424
425 const std::vectorstd::string &FinalCommandLine =
426 ModifiedCommandLine ? *ModifiedCommandLine : CommandLine;
427 auto &FinalFS = ModifiedFS ? ModifiedFS : BaseFS;


To view the defects in Coverity Scan visit, Coverity Scan - Sign in