[clang] [NFC][CLANG] Fix static analyzer bugs about unnecessary object copies… (PR #86808)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 27 07:45:29 PDT 2024
https://github.com/smanna12 created https://github.com/llvm/llvm-project/pull/86808
… with auto keyword
Reported by Static Analyzer Tool:
In clang::installapi::InstallAPIVisitor::VisitFunctionDecl(clang::FunctionDecl const *): Using the auto keyword without an & causes the copy of an object of type DynTypedNode.
>From 64ee510df037daeccb98a3fd9fa7e2ac5c41d279 Mon Sep 17 00:00:00 2001
From: "Manna, Soumi" <soumi.manna at intel.com>
Date: Wed, 27 Mar 2024 07:41:09 -0700
Subject: [PATCH] [NFC][CLANG] Fix static analyzer bugs about unnecessary
object copies with auto keyword
Reported by Static Analyzer Tool:
In clang::installapi::InstallAPIVisitor::VisitFunctionDecl(clang::FunctionDecl const *): Using the auto keyword without an & causes the copy of an object of type DynTypedNode.
---
clang/lib/InstallAPI/Visitor.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/InstallAPI/Visitor.cpp b/clang/lib/InstallAPI/Visitor.cpp
index f8f5d8d53d5691..43878463caccbb 100644
--- a/clang/lib/InstallAPI/Visitor.cpp
+++ b/clang/lib/InstallAPI/Visitor.cpp
@@ -255,7 +255,7 @@ bool InstallAPIVisitor::VisitFunctionDecl(const FunctionDecl *D) {
return true;
// Skip methods in CXX RecordDecls.
- for (auto P : D->getASTContext().getParents(*M)) {
+ for (const auto &P : D->getASTContext().getParents(*M)) {
if (P.get<CXXRecordDecl>())
return true;
}
More information about the cfe-commits
mailing list