[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 4 05:59:32 PDT 2018


lebedev.ri added inline comments.


================
Comment at: clang-tidy/utils/Matchers.cpp:18-19
+
+Matcher<NamedDecl>
+matchesAnyListedName(const std::vector<std::string> &NameList) {
+  SmallString<256> NameRegEx;
----------------
Actually wait, what is this?
It should be something like
```
AST_MATCHER_P(NamedDecl, matchesAnyListedName, std::vector<std::string> &, NameList) {
...
```


================
Comment at: clang-tidy/utils/Matchers.cpp:20
+matchesAnyListedName(const std::vector<std::string> &NameList) {
+  SmallString<256> NameRegEx;
+  llvm::raw_svector_ostream NameOut(NameRegEx);
----------------
lebedev.ri wrote:
> baloghadamsoftware wrote:
> > lebedev.ri wrote:
> > > ```
> > > if(NameList.empty())
> > >   return false;
> > > ```
> > `false`? But this functions returns `Matcher<NamedDecl>`.
> Hm, then `unless(anything())`, or `unless(anything()).matches(Node, Finder, Builder)`.
Are you *sure* it doesn't work? Have you tried?




================
Comment at: clang-tidy/utils/Matchers.cpp:29
+    NameOut << "^(?!.*)";
+  return matchesName(NameRegEx.str());
+}
----------------
baloghadamsoftware wrote:
> lebedev.ri wrote:
> > Why do you need to 'concatenate' all the regexes?
> > Why not simply match in a loop?
> This is what @JonasToth suggested. How to match them in a loop if the function returns a `Matcher<NamedDecl>`?
Are you *sure* it doesn't work? Have you tried?


https://reviews.llvm.org/D52727





More information about the cfe-commits mailing list