forked from OSchip/llvm-project
[libcxx] Fix printf formats in two tests.
rGcc69d211d0d65d7b introduced several uses of `printf` with format directives `%lu` and `%ld` to format values of type `size_t` and `ptrdiff_t` respectively. That doesn't reliably work in all C implementations, because those types aren't necessarily the same thing as 'long int': sometimes they're not even the same size, and when they are the same size, they might be officially defined as int rather than long (for example), which causes clang to emit a diagnostic for the mismatch. C has special-purpose printf modifier letters for these two types, so it's safer to use them. Changed all `%lu` on `size_t` to `%zu`, and all `%ld` on `ptrdiff_t` to `%td`. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D89545
This commit is contained in:
parent
0a7f41739f
commit
4d60467f99
|
@ -31,12 +31,12 @@ struct ContainerAdaptor : public Adaptor {
|
|||
|
||||
template <class Deque>
|
||||
static void print(const Deque& d) {
|
||||
std::printf("%lu : __front_spare() == %lu"
|
||||
" : __back_spare() == %lu"
|
||||
" : __capacity() == %lu"
|
||||
" : bytes allocated == %lu\n",
|
||||
d.size(), d.__front_spare(), d.__back_spare(), d.__capacity(),
|
||||
malloc_allocator_base::outstanding_bytes);
|
||||
std::printf("%zu : __front_spare() == %zu"
|
||||
" : __back_spare() == %zu"
|
||||
" : __capacity() == %zu"
|
||||
" : bytes allocated == %zu\n",
|
||||
d.size(), d.__front_spare(), d.__back_spare(), d.__capacity(),
|
||||
malloc_allocator_base::outstanding_bytes);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -77,7 +77,8 @@ public:
|
|||
bool balanced_allocs() {
|
||||
std::vector<int> temp1, temp2;
|
||||
|
||||
std::printf("Allocations = %lu, deallocations = %lu\n", ca_allocs.size(), ca_deallocs.size());
|
||||
std::printf("Allocations = %zu, deallocations = %zu\n", ca_allocs.size(),
|
||||
ca_deallocs.size());
|
||||
if (ca_allocs.size() != ca_deallocs.size())
|
||||
return false;
|
||||
|
||||
|
@ -85,12 +86,12 @@ bool balanced_allocs() {
|
|||
std::sort(temp1.begin(), temp1.end());
|
||||
temp2.clear();
|
||||
std::unique_copy(temp1.begin(), temp1.end(), std::back_inserter<std::vector<int>>(temp2));
|
||||
std::printf("There were %lu different allocators\n", temp2.size());
|
||||
std::printf("There were %zu different allocators\n", temp2.size());
|
||||
|
||||
for (std::vector<int>::const_iterator it = temp2.begin(); it != temp2.end(); ++it ) {
|
||||
std::ptrdiff_t const allocs = std::count(ca_allocs.begin(), ca_allocs.end(), *it);
|
||||
std::ptrdiff_t const deallocs = std::count(ca_deallocs.begin(), ca_deallocs.end(), *it);
|
||||
std::printf("%d: %ld vs %ld\n", *it, allocs, deallocs);
|
||||
std::printf("%d: %td vs %td\n", *it, allocs, deallocs);
|
||||
if (allocs != deallocs)
|
||||
return false;
|
||||
}
|
||||
|
@ -99,12 +100,12 @@ bool balanced_allocs() {
|
|||
std::sort(temp1.begin(), temp1.end());
|
||||
temp2.clear();
|
||||
std::unique_copy(temp1.begin(), temp1.end(), std::back_inserter<std::vector<int>>(temp2));
|
||||
std::printf("There were %lu different (de)allocators\n", temp2.size());
|
||||
std::printf("There were %zu different (de)allocators\n", temp2.size());
|
||||
|
||||
for (std::vector<int>::const_iterator it = ca_deallocs.begin(); it != ca_deallocs.end(); ++it ) {
|
||||
std::ptrdiff_t const allocs = std::count(ca_allocs.begin(), ca_allocs.end(), *it);
|
||||
std::ptrdiff_t const deallocs = std::count(ca_deallocs.begin(), ca_deallocs.end(), *it);
|
||||
std::printf("%d: %ld vs %ld\n", *it, allocs, deallocs);
|
||||
std::printf("%d: %td vs %td\n", *it, allocs, deallocs);
|
||||
if (allocs != deallocs)
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue