[Lldb-commits] [lldb] 3f2d880 - [ObjC] Wrap namespace-global structs in an anonymous namespace to avoid ODR violations
Davide Italiano via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 14 11:26:31 PDT 2020
Author: Davide Italiano
Date: 2020-07-14T11:26:20-07:00
New Revision: 3f2d880a932970d19bfed88c6900d50c9c3bc203
URL: https://github.com/llvm/llvm-project/commit/3f2d880a932970d19bfed88c6900d50c9c3bc203
DIFF: https://github.com/llvm/llvm-project/commit/3f2d880a932970d19bfed88c6900d50c9c3bc203.diff
LOG: [ObjC] Wrap namespace-global structs in an anonymous namespace to avoid ODR violations
<rdar://problem/65537147>
Differential Revision: https://reviews.llvm.org/D83796
Added:
Modified:
lldb/source/Plugins/Language/ObjC/NSArray.cpp
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index e1c789ce26d8..8d648d8a0861 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -98,42 +98,46 @@ class GenericNSArrayMSyntheticFrontEnd : public NSArrayMSyntheticFrontEndBase {
};
namespace Foundation1010 {
- struct DataDescriptor_32 {
- uint32_t _used;
- uint32_t _offset;
- uint32_t _size : 28;
- uint64_t _priv1 : 4;
- uint32_t _priv2;
- uint32_t _data;
- };
-
- struct DataDescriptor_64 {
- uint64_t _used;
- uint64_t _offset;
- uint64_t _size : 60;
- uint64_t _priv1 : 4;
- uint32_t _priv2;
- uint64_t _data;
- };
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used;
+ uint32_t _offset;
+ uint32_t _size : 28;
+ uint64_t _priv1 : 4;
+ uint32_t _priv2;
+ uint32_t _data;
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used;
+ uint64_t _offset;
+ uint64_t _size : 60;
+ uint64_t _priv1 : 4;
+ uint32_t _priv2;
+ uint64_t _data;
+ };
+ }
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1428 {
- struct DataDescriptor_32 {
- uint32_t _used;
- uint32_t _offset;
- uint32_t _size;
- uint32_t _data;
- };
-
- struct DataDescriptor_64 {
- uint64_t _used;
- uint64_t _offset;
- uint64_t _size;
- uint64_t _data;
- };
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used;
+ uint32_t _offset;
+ uint32_t _size;
+ uint32_t _data;
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used;
+ uint64_t _offset;
+ uint64_t _size;
+ uint64_t _data;
+ };
+ }
using NSArrayMSyntheticFrontEnd =
GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index e4e51de9ddfc..3dc07678f92f 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -278,64 +278,67 @@ namespace Foundation1100 {
}
namespace Foundation1428 {
- struct DataDescriptor_32 {
- uint32_t _used : 26;
- uint32_t _kvo : 1;
- uint32_t _size;
- uint32_t _buffer;
- uint64_t GetSize() { return _size; }
- };
-
- struct DataDescriptor_64 {
- uint64_t _used : 58;
- uint32_t _kvo : 1;
- uint64_t _size;
- uint64_t _buffer;
- uint64_t GetSize() { return _size; }
- };
-
-
-
+ namespace {
+ struct DataDescriptor_32 {
+ uint32_t _used : 26;
+ uint32_t _kvo : 1;
+ uint32_t _size;
+ uint32_t _buffer;
+ uint64_t GetSize() { return _size; }
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _used : 58;
+ uint32_t _kvo : 1;
+ uint64_t _size;
+ uint64_t _buffer;
+ uint64_t GetSize() { return _size; }
+ };
+ }
+
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
}
namespace Foundation1437 {
- 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,
- 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119,
- 6221311, 10066421, 16287743, 26354171, 42641881, 68996069,
- 111638519, 180634607, 292272623, 472907251
- };
-
- static const size_t NSDictionaryNumSizeBuckets = sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
-
- struct DataDescriptor_32 {
- uint32_t _buffer;
- uint32_t _muts;
- uint32_t _used : 25;
- uint32_t _kvo : 1;
- uint32_t _szidx : 6;
+ 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,
+ 214519, 346607, 561109, 907759, 1468927, 2376191, 3845119,
+ 6221311, 10066421, 16287743, 26354171, 42641881, 68996069,
+ 111638519, 180634607, 292272623, 472907251
+ };
+
+ static const size_t NSDictionaryNumSizeBuckets =
+ sizeof(NSDictionaryCapacities) / sizeof(uint64_t);
+
+ struct DataDescriptor_32 {
+ uint32_t _buffer;
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
- uint64_t GetSize() {
- return (_szidx) >= NSDictionaryNumSizeBuckets ?
- 0 : NSDictionaryCapacities[_szidx];
- }
- };
-
- struct DataDescriptor_64 {
- uint64_t _buffer;
- uint32_t _muts;
- uint32_t _used : 25;
- uint32_t _kvo : 1;
- uint32_t _szidx : 6;
+ uint64_t GetSize() {
+ return (_szidx) >= NSDictionaryNumSizeBuckets ?
+ 0 : NSDictionaryCapacities[_szidx];
+ }
+ };
+
+ struct DataDescriptor_64 {
+ uint64_t _buffer;
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
- uint64_t GetSize() {
- return (_szidx) >= NSDictionaryNumSizeBuckets ?
- 0 : NSDictionaryCapacities[_szidx];
- }
- };
+ uint64_t GetSize() {
+ return (_szidx) >= NSDictionaryNumSizeBuckets ?
+ 0 : NSDictionaryCapacities[_szidx];
+ }
+ };
+ }
using NSDictionaryMSyntheticFrontEnd =
GenericNSDictionaryMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
More information about the lldb-commits
mailing list