[clang] 06c9cc7 - [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 28 09:01:26 PDT 2023
Author: Manna, Soumi
Date: 2023-09-28T09:00:55-07:00
New Revision: 06c9cc7eaa8a19820535bf52e8ad8dcecf07caf4
URL: https://github.com/llvm/llvm-project/commit/06c9cc7eaa8a19820535bf52e8ad8dcecf07caf4
DIFF: https://github.com/llvm/llvm-project/commit/06c9cc7eaa8a19820535bf52e8ad8dcecf07caf4.diff
LOG: [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies with auto
Reviewed By: tahonermann
Differential Revision: https://reviews.llvm.org/D159474
Added:
Modified:
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
index 84ea8e2f7ce3851..a344fa7d5d8a78c 100644
--- a/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ b/clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -172,7 +172,7 @@ class ExtractAPIVisitorBase : public RecursiveASTVisitor<Derived> {
SmallVector<SymbolReference> getBases(const CXXRecordDecl *Decl) {
// FIXME: store AccessSpecifier given by inheritance
SmallVector<SymbolReference> Bases;
- for (const auto BaseSpecifier : Decl->bases()) {
+ for (const auto &BaseSpecifier : Decl->bases()) {
// skip classes not inherited as public
if (BaseSpecifier.getAccessSpecifier() != AccessSpecifier::AS_public)
continue;
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index a4a200469f70be3..49cfa7c0d3e3b27 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -2295,7 +2295,7 @@ static void eraseVarsForUnfixableGroupMates(
// Variables will be removed from `FixItsForVariable`:
SmallVector<const VarDecl *, 8> ToErase;
- for (auto [VD, Ignore] : FixItsForVariable) {
+ for (const auto &[VD, Ignore] : FixItsForVariable) {
VarGrpRef Grp = VarGrpMgr.getGroupOfVar(VD);
if (llvm::any_of(Grp,
[&FixItsForVariable](const VarDecl *GrpMember) -> bool {
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index 6ee6e72d99ec57b..3c8668d26c60b76 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -900,7 +900,7 @@ void SymbolGraphSerializer::visitCXXClassRecord(const CXXClassRecord &Record) {
return;
Symbols.emplace_back(std::move(*Class));
- for (const auto Base : Record.Bases)
+ for (const auto &Base : Record.Bases)
serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
if (!Record.ParentInformation.empty())
serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -914,7 +914,7 @@ void SymbolGraphSerializer::visitClassTemplateRecord(
return;
Symbols.emplace_back(std::move(*Class));
- for (const auto Base : Record.Bases)
+ for (const auto &Base : Record.Bases)
serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
if (!Record.ParentInformation.empty())
serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -929,7 +929,7 @@ void SymbolGraphSerializer::visitClassTemplateSpecializationRecord(
Symbols.emplace_back(std::move(*Class));
- for (const auto Base : Record.Bases)
+ for (const auto &Base : Record.Bases)
serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
if (!Record.ParentInformation.empty())
serializeRelationship(RelationshipKind::MemberOf, Record,
@@ -944,7 +944,7 @@ void SymbolGraphSerializer::visitClassTemplatePartialSpecializationRecord(
Symbols.emplace_back(std::move(*Class));
- for (const auto Base : Record.Bases)
+ for (const auto &Base : Record.Bases)
serializeRelationship(RelationshipKind::InheritsFrom, Record, Base);
if (!Record.ParentInformation.empty())
serializeRelationship(RelationshipKind::MemberOf, Record,
More information about the cfe-commits
mailing list