[RDA] Avoid negative shift UB

Avoid "left shift of negative value -1" ubsan errors by casting
to uintptr_t before performing the shift, rather than after.
This commit is contained in:
Nikita Popov 2020-04-09 09:47:15 +02:00
parent 1d3b7370c4
commit 8f66f25f52
1 changed files with 1 additions and 1 deletions

View File

@ -44,7 +44,7 @@ class ReachingDef {
public:
ReachingDef(std::nullptr_t) : Encoded(0) {}
ReachingDef(int Instr) : Encoded((Instr << 2) | 2) {}
ReachingDef(int Instr) : Encoded(((uintptr_t) Instr << 2) | 2) {}
operator int() const { return ((int) Encoded) >> 2; }
};