[PATCH] D65678: Register/MCRegister: Add conversion operators to avoid use of implicit convert to unsigned. NFC
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 11:39:51 PDT 2019
dsanders marked an inline comment as done.
dsanders added inline comments.
================
Comment at: llvm/include/llvm/CodeGen/Register.h:127-128
+ bool operator!=(unsigned Other) const { return Reg != Other; }
+ bool operator==(int Other) const { return Reg == unsigned(Other); }
+ bool operator!=(int Other) const { return Reg != unsigned(Other); }
};
----------------
arsenm wrote:
> Why are both the signed and unsigned versions necessary?
For the unsigned case, it's because it can't tell which operator to use for `MCRegister == unsigned`. It can do either:
* `MCRegister::operator==(*this, MCRegister(Other))`
* or, `unsigned::operator==(unsigned(*this), Other)`
For the signed case, it's the same problem but the `operator==(MCRegister, unsigned)` is also a candidate
https://godbolt.org/z/8JMcTs
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65678/new/
https://reviews.llvm.org/D65678
More information about the llvm-commits
mailing list