[flang-commits] [flang] [flang] Pass unmodified std::vector as const reference (PR #95050)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Jun 10 14:33:40 PDT 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/95050
cppcheck recommends that a std::vector argument be passed as a const reference rather than by value.
Fixes https://github.com/llvm/llvm-project/issues/94929.
>From 99858f3f31c8046b7540c62a1b5efd765f286554 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 10 Jun 2024 14:31:40 -0700
Subject: [PATCH] [flang] Pass unmodified std::vector as const reference
cppcheck recommends that a std::vector argument be
passed as a const reference rather than by value.
Fixes https://github.com/llvm/llvm-project/issues/94929.
---
flang/lib/Semantics/expression.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp
index ae7e6d4cc3609..803c655b3174f 100644
--- a/flang/lib/Semantics/expression.cpp
+++ b/flang/lib/Semantics/expression.cpp
@@ -172,7 +172,8 @@ class ArgumentAnalyzer {
void Dump(llvm::raw_ostream &);
private:
- MaybeExpr TryDefinedOp(std::vector<const char *>, parser::MessageFixedText);
+ MaybeExpr TryDefinedOp(
+ const std::vector<const char *> &, parser::MessageFixedText);
MaybeExpr TryBoundOp(const Symbol &, int passIndex);
std::optional<ActualArgument> AnalyzeExpr(const parser::Expr &);
std::optional<ActualArgument> AnalyzeVariable(const parser::Variable &);
@@ -4410,7 +4411,7 @@ MaybeExpr ArgumentAnalyzer::TryDefinedOp(
}
MaybeExpr ArgumentAnalyzer::TryDefinedOp(
- std::vector<const char *> oprs, parser::MessageFixedText error) {
+ const std::vector<const char *> &oprs, parser::MessageFixedText error) {
if (oprs.size() == 1) {
return TryDefinedOp(oprs[0], error);
}
More information about the flang-commits
mailing list