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

2024-04-01 Thread Amila Senadheera via cfe-commits

https://github.com/Amila-Rukshan updated 
https://github.com/llvm/llvm-project/pull/87273

>From 4f8349936403d29ac14179fb7d9e1429a09914ff Mon Sep 17 00:00:00 2001
From: amila 
Date: Tue, 2 Apr 2024 00:15:59 +0530
Subject: [PATCH] use move semantics for NodeKinds and update possible callers
 to use it

Signed-off-by: amila 
---
 clang/lib/ASTMatchers/Dynamic/Marshallers.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h 
b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
index c76ddf17b719d4..0e640cbada7268 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -937,7 +937,7 @@ class MapAnyOfMatcherDescriptor : public MatcherDescriptor {
 public:
   MapAnyOfMatcherDescriptor(ASTNodeKind CladeNodeKind,
 std::vector NodeKinds)
-  : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
+  : CladeNodeKind(CladeNodeKind), NodeKinds(std::move(NodeKinds)) {}
 
   VariantMatcher create(SourceRange NameRange, ArrayRef Args,
 Diagnostics *Error) const override {
@@ -1026,7 +1026,7 @@ class MapAnyOfBuilderDescriptor : public 
MatcherDescriptor {
 }
 
 return std::make_unique(CladeNodeKind,
-   NodeKinds);
+   std::move(NodeKinds));
   }
 
   bool isVariadic() const override { return true; }

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-04-01 Thread Oliver Stöneberg via cfe-commits

firewave wrote:

Depending on the calling code the fix might actually be the introduction of 
`std::move()`.

This is a known issue upstream: https://trac.cppcheck.net/ticket/12384.

https://github.com/llvm/llvm-project/pull/87273
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-04-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Amila Senadheera (Amila-Rukshan)


Changes

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 NodeKinds)
+const std::vector& NodeKinds)
   : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
 
   VariantMatcher create(SourceRange NameRange, ArrayRef Args,

``




https://github.com/llvm/llvm-project/pull/87273
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-04-01 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/87273
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2024-04-01 Thread Amila Senadheera via cfe-commits

https://github.com/Amila-Rukshan created 
https://github.com/llvm/llvm-project/pull/87273

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++ .
```

>From addf9911ffb22eb96f6b26e6a7eabcb8cc325123 Mon Sep 17 00:00:00 2001
From: amila 
Date: Tue, 2 Apr 2024 00:15:59 +0530
Subject: [PATCH] cppcheck: pass NodeKinds by const reference

Signed-off-by: amila 
---
 clang/lib/ASTMatchers/Dynamic/Marshallers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 NodeKinds)
+const std::vector& NodeKinds)
   : CladeNodeKind(CladeNodeKind), NodeKinds(NodeKinds) {}
 
   VariantMatcher create(SourceRange NameRange, ArrayRef Args,

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits