[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:59 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (smanna12)
<details>
<summary>Changes</summary>
… 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.
---
Full diff: https://github.com/llvm/llvm-project/pull/86808.diff
1 Files Affected:
- (modified) clang/lib/InstallAPI/Visitor.cpp (+1-1)
``````````diff
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;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/86808
More information about the cfe-commits
mailing list