diff options
| author | Roman Lebedev <lebedev.ri@gmail.com> | 2017-09-27 15:59:16 +0000 |
|---|---|---|
| committer | Roman Lebedev <lebedev.ri@gmail.com> | 2017-09-27 15:59:16 +0000 |
| commit | 7c983671f2a7b7d762bd2cca0834b0a0db8df777 (patch) | |
| tree | 269e02f1264bb25680f352c70d095ff3439b6334 /llvm/include | |
| parent | 04ce5ac3069057db2cfd0fe571278c19a27cc548 (diff) | |
| download | bcm5719-llvm-7c983671f2a7b7d762bd2cca0834b0a0db8df777.tar.gz bcm5719-llvm-7c983671f2a7b7d762bd2cca0834b0a0db8df777.zip | |
[Support] mapped_file_region: store size as size_t
Summary:
Found when testing stage-2 build with D38101.
```
In file included from /build/llvm/lib/Support/Path.cpp:1045:
/build/llvm/lib/Support/Unix/Path.inc:648:14: error: comparison 'uint64_t' (aka 'unsigned long') > 18446744073709551615 is always false [-Werror,-Wtautological-constant-compare]
if (length > std::numeric_limits<size_t>::max()) {
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
`size_t` is `uint64_t` here, apparently, thus any `uint64_t` value
always fits into `size_t`.
Initial patch was to use some preprocessor logic to
not check if the size is known to fit at compile time.
But Zachary Turner suggested using this approach.
Reviewers: Bigcheese, rafael, zturner, mehdi_amini
Reviewed by (via email): zturner
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D38132
llvm-svn: 314312
Diffstat (limited to 'llvm/include')
| -rw-r--r-- | llvm/include/llvm/Support/FileSystem.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/FileSystem.h b/llvm/include/llvm/Support/FileSystem.h index 8b74d766ebe..e8460ca0a31 100644 --- a/llvm/include/llvm/Support/FileSystem.h +++ b/llvm/include/llvm/Support/FileSystem.h @@ -745,7 +745,7 @@ public: private: /// Platform-specific mapping state. - uint64_t Size; + size_t Size; void *Mapping; std::error_code init(int FD, uint64_t Offset, mapmode Mode); @@ -758,12 +758,12 @@ public: /// \param fd An open file descriptor to map. mapped_file_region takes /// ownership if closefd is true. It must have been opended in the correct /// mode. - mapped_file_region(int fd, mapmode mode, uint64_t length, uint64_t offset, + mapped_file_region(int fd, mapmode mode, size_t length, uint64_t offset, std::error_code &ec); ~mapped_file_region(); - uint64_t size() const; + size_t size() const; char *data() const; /// Get a const view of the data. Modifying this memory has undefined |

