AST Matcher for template parameters passed by reference?

Given the following test.cpp-

#include <vector>
using namespace std;

class MyData {};
class MoreData {};

class MyClass { 
public:
  void Method2(vector<int> vec){}  
  void Method3(const vector<int>& vec){}
  void Method4(vector<MoreData> vec){}
  void Method5(const vector<MoreData>& vec){} 
  void Method7(vector<MyData> vec){}    // Match works for this
  void Method8(const vector<MyData>& vec){} // How to match by reference?
};

I can create a matcher that will match functions that pass a vector of MyData by value which I verified using clang-query>

cxxMethodDecl(hasAnyParameter(hasType(allOf(cxxRecordDecl(matchesName("vector")),
 classTemplateSpecializationDecl(hasAnyTemplateArgument(templateArgument(
 refersToType(hasDeclaration(recordDecl(matchesName("MyData")))))))))))

How can I create a similar matcher to do the same thing when the vector is passed by reference?

Kudos to This Question for getting me this far

Source: Windows Questions C++

LEAVE A COMMENT