diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index 0992f5d4a54..2366e67f2d7 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -71,12 +71,12 @@ static inline char *utohex_buffer(IntTy X, char *BufferEnd, bool LowerCase = fal static inline std::string utohexstr(uint64_t X, bool LowerCase = false) { char Buffer[17]; - return utohex_buffer(X, Buffer+17, LowerCase); + return utohex_buffer(X, std::end(Buffer), LowerCase); } static inline std::string utostr_32(uint32_t X, bool isNeg = false) { char Buffer[11]; - char *BufPtr = Buffer+11; + char *BufPtr = std::end(Buffer); if (X == 0) *--BufPtr = '0'; // Handle special case... @@ -87,12 +87,12 @@ static inline std::string utostr_32(uint32_t X, bool isNeg = false) { if (isNeg) *--BufPtr = '-'; // Add negative sign... - return std::string(BufPtr, Buffer+11); + return std::string(BufPtr, std::end(Buffer)); } static inline std::string utostr(uint64_t X, bool isNeg = false) { char Buffer[21]; - char *BufPtr = Buffer+21; + char *BufPtr = std::end(Buffer); if (X == 0) *--BufPtr = '0'; // Handle special case... @@ -102,7 +102,7 @@ static inline std::string utostr(uint64_t X, bool isNeg = false) { } if (isNeg) *--BufPtr = '-'; // Add negative sign... - return std::string(BufPtr, Buffer+21); + return std::string(BufPtr, std::end(Buffer)); } diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 15813fd3e66..a278a3b4660 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -141,7 +141,7 @@ raw_ostream &raw_ostream::operator<<(unsigned long long N) { return this->operator<<(static_cast(N)); char NumberBuffer[20]; - char *EndPtr = NumberBuffer+sizeof(NumberBuffer); + char *EndPtr = std::end(NumberBuffer); char *CurPtr = EndPtr; while (N) { @@ -167,7 +167,7 @@ raw_ostream &raw_ostream::write_hex(unsigned long long N) { return *this << '0'; char NumberBuffer[20]; - char *EndPtr = NumberBuffer+sizeof(NumberBuffer); + char *EndPtr = std::end(NumberBuffer); char *CurPtr = EndPtr; while (N) {