[ObjC] Wrap namespace-global structs in an anonymous namespace to avoid ODR violations

<rdar://problem/65537147>

Differential Revision:  https://reviews.llvm.org/D83796
This commit is contained in:
Davide Italiano 2020-07-14 11:25:32 -07:00
parent 9b974dfa72
commit 3f2d880a93
2 changed files with 88 additions and 81 deletions

View File

@ -98,6 +98,7 @@ private:
};
namespace Foundation1010 {
namespace {
struct DataDescriptor_32 {
uint32_t _used;
uint32_t _offset;
@ -115,12 +116,14 @@ namespace Foundation1010 {
uint32_t _priv2;
uint64_t _data;
};
}
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1428 {
namespace {
struct DataDescriptor_32 {
uint32_t _used;
uint32_t _offset;
@ -134,6 +137,7 @@ namespace Foundation1428 {
uint64_t _size;
uint64_t _data;
};
}
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;

View File

@ -278,6 +278,7 @@ namespace Foundation1100 {
}
namespace Foundation1428 {
namespace {
struct DataDescriptor_32 {
uint32_t _used : 26;
uint32_t _kvo : 1;
@ -293,14 +294,14 @@ namespace Foundation1428 {
uint64_t _buffer;
uint64_t GetSize() { return _size; }
};
}
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1437 {
namespace {
static const uint64_t NSDictionaryCapacities[] = {
0, 3, 7, 13, 23, 41, 71, 127, 191, 251, 383, 631, 1087, 1723,
2803, 4523, 7351, 11959, 19447, 31231, 50683, 81919, 132607,
@ -309,7 +310,8 @@ namespace Foundation1437 {
111638519, 180634607, 292272623, 472907251
};
static const size_t NSDictionaryNumSizeBuckets = sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
static const size_t NSDictionaryNumSizeBuckets =
sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
struct DataDescriptor_32 {
uint32_t _buffer;
@ -336,6 +338,7 @@ namespace Foundation1437 {
0 : NSDictionaryCapacities[_szidx];
}
};
}
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;