Matching all the overloaded operators

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Matching all the overloaded operators

David Zarzycki via cfe-dev
Hi all,

I was looking for a matcher all overloaded operators.

`cxxMethodDecl(hasOverloadedOperatorName("+"))` matches overloaded "+". How do I modify this to match all operator overloads?

Any help would be appreciated.

Thanks and regards
Shraiysh


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Matching all the overloaded operators

David Zarzycki via cfe-dev
On Mon, Dec 16, 2019 at 5:50 AM Shraiysh Vaishay via cfe-dev
<[hidden email]> wrote:
>
> Hi all,
>
> I was looking for a matcher all overloaded operators.
>
> `cxxMethodDecl(hasOverloadedOperatorName("+"))` matches overloaded "+". How do I modify this to match all operator overloads?
>
> Any help would be appreciated.

We don't currently have a matcher that makes this trivial (I was
thinking cxxMethodDecl(hasOverloadedOperatorName(anything())) might
work, but there's a type mismatch between anything() and a string).

You could add a matcher for this pretty easily if you are in C++ with:

AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
  return Node.isOverloadedOperator();
}

~Aaron

>
> Thanks and regards
> Shraiysh
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Matching all the overloaded operators

David Zarzycki via cfe-dev
Hi Aaron,

Thanks for the answer.

Regards
Shraiysh

On Mon, Dec 16, 2019, 7:09 PM Aaron Ballman <[hidden email]> wrote:
On Mon, Dec 16, 2019 at 5:50 AM Shraiysh Vaishay via cfe-dev
<[hidden email]> wrote:
>
> Hi all,
>
> I was looking for a matcher all overloaded operators.
>
> `cxxMethodDecl(hasOverloadedOperatorName("+"))` matches overloaded "+". How do I modify this to match all operator overloads?
>
> Any help would be appreciated.

We don't currently have a matcher that makes this trivial (I was
thinking cxxMethodDecl(hasOverloadedOperatorName(anything())) might
work, but there's a type mismatch between anything() and a string).

You could add a matcher for this pretty easily if you are in C++ with:

AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
  return Node.isOverloadedOperator();
}

~Aaron

>
> Thanks and regards
> Shraiysh
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev