Skip to content

Commit b72788c

Browse files
committed
runtime: namespace LLVMSupport fork
This adds the `__swift::__runtime` inline namespace to the LLVMSupport interfaces. This avoids an ODR violation when LLVM and Swift are in the same address space. It also will aid in the process of pruning the LLVMSupport library by ensuring that accidental leakage of the llvm namespace does not allow us to remove symbols which we rely on.
1 parent 3fa1d1f commit b72788c

File tree

118 files changed

+328
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+328
-84
lines changed

stdlib/include/llvm/ADT/APFloat.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
llvm_unreachable("Unexpected semantics"); \
3232
} while (false)
3333

34+
inline namespace __swift { inline namespace __runtime {
3435
namespace llvm {
3536

3637
struct fltSemantics;
@@ -1321,6 +1322,7 @@ inline APFloat maximum(const APFloat &A, const APFloat &B) {
13211322
}
13221323

13231324
} // namespace llvm
1325+
}} // swift::runtime
13241326

13251327
#undef APFLOAT_DISPATCH_ON_SEMANTICS
13261328
#endif // LLVM_ADT_APFLOAT_H

stdlib/include/llvm/ADT/APInt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <cstring>
2323
#include <string>
2424

25+
inline namespace __swift { inline namespace __runtime {
2526
namespace llvm {
2627
class FoldingSetNodeID;
2728
class StringRef;
@@ -2286,5 +2287,6 @@ void StoreIntToMemory(const APInt &IntVal, uint8_t *Dst, unsigned StoreBytes);
22862287
void LoadIntFromMemory(APInt &IntVal, uint8_t *Src, unsigned LoadBytes);
22872288

22882289
} // namespace llvm
2290+
}} // namespace swift::runtime
22892291

22902292
#endif

stdlib/include/llvm/ADT/APSInt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "llvm/ADT/APInt.h"
1818

19+
inline namespace __swift { inline namespace __runtime {
1920
namespace llvm {
2021

2122
class LLVM_NODISCARD APSInt : public APInt {
@@ -349,5 +350,6 @@ inline raw_ostream &operator<<(raw_ostream &OS, const APSInt &I) {
349350
}
350351

351352
} // end namespace llvm
353+
}} // namespace swift::runtime
352354

353355
#endif

stdlib/include/llvm/ADT/ArrayRef.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <type_traits>
2525
#include <vector>
2626

27+
inline namespace __swift { inline namespace __runtime {
2728
namespace llvm {
2829

2930
/// ArrayRef - Represent a constant reference to an array (0 or more elements
@@ -554,5 +555,6 @@ namespace llvm {
554555
}
555556

556557
} // end namespace llvm
558+
}} // namespace swift::runtime
557559

558560
#endif // LLVM_ADT_ARRAYREF_H

stdlib/include/llvm/ADT/BitVector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <cstring>
2626
#include <utility>
2727

28+
inline namespace __swift { inline namespace __runtime {
2829
namespace llvm {
2930

3031
/// ForwardIterator for the bits that are set.
@@ -955,6 +956,7 @@ template <> struct DenseMapInfo<BitVector> {
955956
}
956957
};
957958
} // end namespace llvm
959+
}} // namespace swift::runtime
958960

959961
namespace std {
960962
/// Implement std::swap in terms of BitVector swap.

stdlib/include/llvm/ADT/DenseMap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <type_traits>
3232
#include <utility>
3333

34+
inline namespace __swift { inline namespace __runtime {
3435
namespace llvm {
3536

3637
namespace detail {
@@ -1304,5 +1305,6 @@ inline size_t capacity_in_bytes(const DenseMap<KeyT, ValueT, KeyInfoT> &X) {
13041305
}
13051306

13061307
} // end namespace llvm
1308+
}} // namespace swift::runtime
13071309

13081310
#endif // LLVM_ADT_DENSEMAP_H

stdlib/include/llvm/ADT/DenseMapInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cstdint>
2222
#include <utility>
2323

24+
inline namespace __swift { inline namespace __runtime {
2425
namespace llvm {
2526

2627
namespace detail {
@@ -348,5 +349,6 @@ template <> struct DenseMapInfo<hash_code> {
348349
};
349350

350351
} // end namespace llvm
352+
}} // namespace swift::runtime
351353

352354
#endif // LLVM_ADT_DENSEMAPINFO_H

stdlib/include/llvm/ADT/DenseSet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <iterator>
2424
#include <utility>
2525

26+
inline namespace __swift { inline namespace __runtime {
2627
namespace llvm {
2728

2829
namespace detail {
@@ -285,5 +286,6 @@ class SmallDenseSet
285286
};
286287

287288
} // end namespace llvm
289+
}} // namespace swift::runtime
288290

289291
#endif // LLVM_ADT_DENSESET_H

stdlib/include/llvm/ADT/EpochTracker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <cstdint>
2121

22+
inline namespace __swift { inline namespace __runtime {
2223
namespace llvm {
2324

2425
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
@@ -94,5 +95,6 @@ class DebugEpochBase {
9495
#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS
9596

9697
} // namespace llvm
98+
}} // namespace swift::runtime
9799

98100
#endif

stdlib/include/llvm/ADT/FloatingPointMode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/ADT/StringSwitch.h"
1717
#include "llvm/Support/raw_ostream.h"
1818

19+
inline namespace __swift { inline namespace __runtime {
1920
namespace llvm {
2021

2122
/// Rounding mode.
@@ -173,5 +174,6 @@ void DenormalMode::print(raw_ostream &OS) const {
173174
}
174175

175176
}
177+
}} // namespace swift::runtime
176178

177179
#endif // LLVM_FLOATINGPOINTMODE_H

0 commit comments

Comments
 (0)