[clang] cppcheck: pass NodeKinds by const reference (PR #87273)

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 1 11:54:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Amila Senadheera (Amila-Rukshan)

<details>
<summary>Changes</summary>

Fix the cppcheck identified performance issue: https://github.com/llvm/llvm-project/issues/87248

I ran the following to check the possible perf issue in `clang/lib/ASTMatchers/Dynamic` directory:
```
cppcheck --enable=performance --language=c++ .
```

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


1 Files Affected:

- (modified) clang/lib/ASTMatchers/Dynamic/Marshallers.h (+1-1) 


``````````diff
diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
index c76ddf17b719d4..fc0771d7496df2 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -936,7 +936,7 @@ class MapAnyOfMatcherDescriptor : public MatcherDescriptor {
 
 public:
   MapAnyOfMatcherDescriptor(ASTNodeKind CladeNodeKind,
-                            std::vector<ASTNodeKind> NodeKinds)
+                            const std::vector<ASTNodeKind>& NodeKinds)
       : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
 
   VariantMatcher create(SourceRange NameRange, ArrayRef<ParserValue> Args,

``````````

</details>


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


More information about the cfe-commits mailing list