This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Make cxxOperatorCallExpr matchers API-compatible with n-ary operators
ClosedPublic

Authored by steveire on Jan 5 2021, 3:31 PM.

Details

Summary

This makes them composable with mapAnyOf().

Diff Detail

Event Timeline

steveire requested review of this revision.Jan 5 2021, 3:31 PM
steveire created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2021, 3:31 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Jan 11 2021, 6:33 AM
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
1994

Not certain how much we want to care about it, but I think we need to check whether there's exactly one parameter of type int to meet the language rules for these to be replacement APIs: http://eel.is/c++draft/over.inc#1

e.g., the user could do something rather unlikely like: int operator++(float); for their overload and we're report it as being equivalent when it really isn't.

2142–2150

Can we reuse the implementation from getOpName() to simplify this?

steveire added inline comments.Jan 14 2021, 12:27 PM
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
1994

It doesn't compile with the big three at least: https://godbolt.org/z/Kns8We

So, we can't write a test for it.

So, we shouldn't add a condition for it.

2142–2150

Yes, good idea. I went one step further and removed this new function entirely.

aaron.ballman accepted this revision.Jan 15 2021, 4:56 AM

LGTM

clang/include/clang/ASTMatchers/ASTMatchersInternal.h
1994

I had a think-o there and realize now that such a declaration is illegal per http://eel.is/c++draft/over.oper#over.inc-1

So agreed that we shouldn't handle it.

This revision is now accepted and ready to land.Jan 15 2021, 4:56 AM
This revision was landed with ongoing or failed builds.Jan 16 2021, 5:21 AM
This revision was automatically updated to reflect the committed changes.