[clang] f435f55 - [Lex] Use llvm::byteswap instead of sys::getSwappedBytes (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 23 13:30:22 PDT 2023
Author: Kazu Hirata
Date: 2023-09-23T13:30:16-07:00
New Revision: f435f55d58542ecde0e66460555ccbcbca355cc5
URL: https://github.com/llvm/llvm-project/commit/f435f55d58542ecde0e66460555ccbcbca355cc5
DIFF: https://github.com/llvm/llvm-project/commit/f435f55d58542ecde0e66460555ccbcbca355cc5.diff
LOG: [Lex] Use llvm::byteswap instead of sys::getSwappedBytes (NFC)
Added:
Modified:
clang/lib/Lex/HeaderMap.cpp
clang/unittests/Lex/HeaderMapTestUtils.h
Removed:
################################################################################
diff --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index 2b2642673586054..22a1532c2d93838 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/lib/Lex/HeaderMap.cpp
@@ -87,9 +87,8 @@ bool HeaderMapImpl::checkHeader(const llvm::MemoryBuffer &File,
// Check the number of buckets. It should be a power of two, and there
// should be enough space in the file for all of them.
- uint32_t NumBuckets = NeedsByteSwap
- ? llvm::sys::getSwappedBytes(Header->NumBuckets)
- : Header->NumBuckets;
+ uint32_t NumBuckets =
+ NeedsByteSwap ? llvm::byteswap(Header->NumBuckets) : Header->NumBuckets;
if (!llvm::isPowerOf2_32(NumBuckets))
return false;
if (File.getBufferSize() <
diff --git a/clang/unittests/Lex/HeaderMapTestUtils.h b/clang/unittests/Lex/HeaderMapTestUtils.h
index 271d0588fc80277..799bfcb95e58971 100644
--- a/clang/unittests/Lex/HeaderMapTestUtils.h
+++ b/clang/unittests/Lex/HeaderMapTestUtils.h
@@ -33,11 +33,10 @@ template <unsigned NumBuckets, unsigned NumBytes> struct HMapFileMock {
}
void swapBytes() {
- using llvm::sys::getSwappedBytes;
- Header.Magic = getSwappedBytes(Header.Magic);
- Header.Version = getSwappedBytes(Header.Version);
- Header.NumBuckets = getSwappedBytes(Header.NumBuckets);
- Header.StringsOffset = getSwappedBytes(Header.StringsOffset);
+ Header.Magic = llvm::byteswap(Header.Magic);
+ Header.Version = llvm::byteswap(Header.Version);
+ Header.NumBuckets = llvm::byteswap(Header.NumBuckets);
+ Header.StringsOffset = llvm::byteswap(Header.StringsOffset);
}
std::unique_ptr<llvm::MemoryBuffer> getBuffer() {
More information about the cfe-commits
mailing list