[flang-commits] [flang] [flang] Pass unmodified std::vector as const reference (PR #95050)

via flang-commits flang-commits at lists.llvm.org
Mon Jun 10 14:34:11 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/95050.diff


1 Files Affected:

- (modified) flang/lib/Semantics/expression.cpp (+3-2) 


``````````diff
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);
   }

``````````

</details>


https://github.com/llvm/llvm-project/pull/95050


More information about the flang-commits mailing list