diff options
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index a02ecaa762a..cdb72b95ad7 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -625,7 +625,12 @@ public: /// Negates *this using two's complement logic. /// /// \returns An APInt value representing the negation of *this. - APInt operator-() const { return APInt(BitWidth, 0) - (*this); } + APInt operator-() const { + APInt Result(*this); + Result.flipAllBits(); + ++Result; + return Result; + } /// \brief Logical negation operator. /// |