HomePhabricator

[c++20] Add rewriting from comparison operators to <=> / ==.

Description

[c++20] Add rewriting from comparison operators to <=> / ==.

This adds support for rewriting <, >, <=, and >= to a normal or reversed
call to operator<=>, for rewriting != to a normal or reversed call to
operator==, and for rewriting <=> and == to reversed forms of those same
operators.

Note that this is a breaking change for various C++17 code patterns,
including some in use in LLVM. The most common patterns (where an
operator== becomes ambiguous with a reversed form of itself) are still
accepted under this patch, as an extension (with a warning). I'm hopeful
that we can get the language rules fixed before C++20 ships, and the
extension warning is aimed primarily at providing data to inform that
decision.

Details

Committed
rsmithOct 18 2019, 5:04 PM
Parents
rL375305: [c++20] Add CXXRewrittenBinaryOperator to represent a comparison
Branches
Unknown
Tags
Unknown

Event Timeline

xbolva00 added a subscriber: xbolva00.EditedOct 22 2019, 8:59 AM

Hello Richard,

GCC 7 warns:
/home/xbolva00/LLVM/llvm-project/clang/include/clang/Sema/Overload.h:812:48: warning: ‘clang::OverloadCandidate::RewriteKind’ is too small to hold all values of ‘enum clang::OverloadCandidateRewriteKind’

OverloadCandidateRewriteKind RewriteKind : 2;