Author: Manna, Soumi Date: 2023-04-17T21:33:21-04:00 New Revision: 18a3d9e5b318133611ebc88bbe82ca9a2ca56f1d
URL: https://github.com/llvm/llvm-project/commit/18a3d9e5b318133611ebc88bbe82ca9a2ca56f1d DIFF: https://github.com/llvm/llvm-project/commit/18a3d9e5b318133611ebc88bbe82ca9a2ca56f1d.diff LOG: [NFC][clang] Fix coverity static analyzer concerns about AUTO_CAUSES_COPY Reported by Coverity: AUTO_CAUSES_COPY Unnecessary object copies can affect performance. 1. [NFC] Fix auto keyword use without an & causes the copy of an object of type SimpleRegistryEntry in clang::getAttributePluginInstances() 2. [NFC] Fix auto keyword use without an & causes the copy of an object of type tuple in CheckStmtInlineAttr<clang::NoInlineAttr, 2>(clang::Sema &, clang::Stmt const *, clang::Stmt const *, clang::AttributeCommonInfo const &) 3. [NFC] Fix auto keyword use without an & causes the copy of an object of type QualType in <unnamed>::SystemZTargetCodeGenInfo::isVectorTypeBased(clang::Type const *, bool) 4. [NFC] Fix auto keyword use without an & causes the copy of an object of type Policy in <unnamed>::RISCVIntrinsicManagerImpl::InitIntrinsicList() 5. [NFC] Fix auto keyword use without an & causes the copy of an object of type pair in checkUndefinedButUsed(clang::Sema &) Reviewed By: tahonermann Differential Revision: <https://reviews.llvm.org/D147543> Added: Modified: clang/lib/Basic/ParsedAttrInfo.cpp clang/lib/CodeGen/TargetInfo.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaRISCVVectorLookup.cpp clang/lib/Sema/SemaStmtAttr.cpp Removed: ################################################################################ diff --git a/clang/lib/Basic/ParsedAttrInfo.cpp b/clang/lib/Basic/ParsedAttrInfo.cpp index 7757f30da511d..16fa314b642b9 100644 --- a/clang/lib/Basic/ParsedAttrInfo.cpp +++ b/clang/lib/Basic/ParsedAttrInfo.cpp @@ -25,7 +25,7 @@ clang::getAttributePluginInstances() { static llvm::ManagedStatic<std::list<std::unique_ptr<ParsedAttrInfo>>> PluginAttrInstances; if (PluginAttrInstances->empty()) - for (auto It : ParsedAttrInfoRegistry::entries()) + for (const auto &It : ParsedAttrInfoRegistry::entries()) PluginAttrInstances->emplace_back(It.instantiate()); return *PluginAttrInstances; diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index e8761879b7f05..e50e07a531b55 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -7916,7 +7916,7 @@ bool SystemZTargetCodeGenInfo::isVectorTypeBased(const Type *Ty, if (isVectorTypeBased(FT->getReturnType().getTypePtr(), /*IsParam*/true)) return true; if (const FunctionProtoType *Proto = Ty->getAs<FunctionProtoType>()) - for (auto ParamType : Proto->getParamTypes()) + for (const auto &ParamType : Proto->getParamTypes()) if (isVectorTypeBased(ParamType.getTypePtr(), /*IsParam*/true)) return true; diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index e1b309bd01938..76dc77d17092b 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -865,7 +865,7 @@ static void checkUndefinedButUsed(Sema &S) { S.getUndefinedButUsed(Undefined); if (Undefined.empty()) return; - for (auto Undef : Undefined) { + for (const auto &Undef : Undefined) { ValueDecl *VD = cast<ValueDecl>(Undef.first); SourceLocation UseLoc = Undef.second; diff --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp b/clang/lib/Sema/SemaRISCVVectorLookup.cpp index 3e3d4d6fc5c78..3e98da5f8b8f4 100644 --- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp +++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp @@ -253,7 +253,7 @@ void RISCVIntrinsicManagerImpl::InitIntrinsicList() { // Create non-masked policy intrinsic. if (Record.UnMaskedPolicyScheme != PolicyScheme::SchemeNone) { - for (auto P : SupportedUnMaskedPolicies) { + for (const auto &P : SupportedUnMaskedPolicies) { llvm::SmallVector<PrototypeDescriptor> PolicyPrototype = RVVIntrinsic::computeBuiltinTypes( BasicProtoSeq, /*IsMasked=*/false, diff --git a/clang/lib/Sema/SemaStmtAttr.cpp b/clang/lib/Sema/SemaStmtAttr.cpp index 50cb5b50aa0de..860a5a8524ec7 100644 --- a/clang/lib/Sema/SemaStmtAttr.cpp +++ b/clang/lib/Sema/SemaStmtAttr.cpp @@ -238,7 +238,7 @@ static bool CheckStmtInlineAttr(Sema &SemaRef, const Stmt *OrigSt, << A; } - for (auto Tup : + for (const auto &Tup : llvm::zip_longest(OrigCEF.getCallExprs(), CEF.getCallExprs())) { // If the original call expression already had a callee, we already // diagnosed this, so skip it here. We can't skip if there isn't a 1:1 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits