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

+2
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

+2
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

+2
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

+2
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

+2
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

+2
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

+2
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

+2
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

+2
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

+2
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

stdlib/include/llvm/ADT/FoldingSet.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <cstdint>
2424
#include <utility>
2525

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

2829
/// This folding set used for two purposes:
@@ -803,5 +804,6 @@ struct FoldingSetTrait<std::pair<T1, T2>> {
803804
};
804805

805806
} // end namespace llvm
807+
}} // namespace swift::runtime
806808

807809
#endif // LLVM_ADT_FOLDINGSET_H

stdlib/include/llvm/ADT/FunctionExtras.h

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "llvm/Support/type_traits.h"
3939
#include <memory>
4040

41+
inline namespace __swift { inline namespace __runtime {
4142
namespace llvm {
4243

4344
template <typename FunctionT> class unique_function;
@@ -289,5 +290,6 @@ class unique_function<ReturnT(ParamTs...)> {
289290
};
290291

291292
} // end namespace llvm
293+
}} // namespace swift::runtime
292294

293295
#endif // LLVM_ADT_FUNCTION_H

stdlib/include/llvm/ADT/Hashing.h

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <string>
5555
#include <utility>
5656

57+
inline namespace __swift { inline namespace __runtime {
5758
namespace llvm {
5859

5960
/// An opaque object representing a hash code.
@@ -653,5 +654,6 @@ hash_code hash_value(const std::basic_string<T> &arg) {
653654
}
654655

655656
} // namespace llvm
657+
}} // namespace swift::runtime
656658

657659
#endif

stdlib/include/llvm/ADT/IntrusiveRefCntPtr.h

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include <cassert>
6060
#include <cstddef>
6161

62+
inline namespace __swift { inline namespace __runtime {
6263
namespace llvm {
6364

6465
/// A CRTP mixin class that adds reference counting to a type.
@@ -265,5 +266,6 @@ template <class T> struct simplify_type<const IntrusiveRefCntPtr<T>> {
265266
};
266267

267268
} // end namespace llvm
269+
}} // namespace swift::runtime
268270

269271
#endif // LLVM_ADT_INTRUSIVEREFCNTPTR_H

stdlib/include/llvm/ADT/None.h

+2
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
#ifndef LLVM_ADT_NONE_H
1616
#define LLVM_ADT_NONE_H
1717

18+
inline namespace __swift { inline namespace __runtime {
1819
namespace llvm {
1920
/// A simple null object to allow implicit construction of Optional<T>
2021
/// and similar types without having to spell out the specialization's name.
2122
// (constant value 1 in an attempt to workaround MSVC build issue... )
2223
enum class NoneType { None = 1 };
2324
const NoneType None = NoneType::None;
2425
}
26+
}} // swift::runtime
2527

2628
#endif

stdlib/include/llvm/ADT/Optional.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <new>
2424
#include <utility>
2525

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

2829
class raw_ostream;
@@ -441,5 +442,6 @@ raw_ostream &operator<<(raw_ostream &OS, const Optional<T> &O) {
441442
}
442443

443444
} // end namespace llvm
445+
}} // namespace swift::runtime
444446

445447
#endif // LLVM_ADT_OPTIONAL_H

stdlib/include/llvm/ADT/PointerIntPair.h

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cstdint>
2121
#include <limits>
2222

23+
inline namespace __swift { inline namespace __runtime {
2324
namespace llvm {
2425

2526
template <typename T> struct DenseMapInfo;
@@ -240,5 +241,6 @@ struct PointerLikeTypeTraits<
240241
};
241242

242243
} // end namespace llvm
244+
}} // namespace swift::runtime
243245

244246
#endif // LLVM_ADT_POINTERINTPAIR_H

stdlib/include/llvm/ADT/PointerUnion.h

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cstddef>
2222
#include <cstdint>
2323

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

2627
template <typename T> struct PointerUnionTypeSelectorReturn {
@@ -295,5 +296,6 @@ template <typename ...PTs> struct DenseMapInfo<PointerUnion<PTs...>> {
295296
};
296297

297298
} // end namespace llvm
299+
}} // swift::runtime
298300

299301
#endif // LLVM_ADT_POINTERUNION_H

stdlib/include/llvm/ADT/STLExtras.h

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <random> // for std::mt19937
4040
#endif
4141

42+
inline namespace __swift { inline namespace __runtime {
4243
namespace llvm {
4344

4445
// Only used by compiler if both template types are the same. Useful when
@@ -1955,5 +1956,6 @@ template <class Ptr> auto to_address(const Ptr &P) { return P.operator->(); }
19551956
template <class T> constexpr T *to_address(T *P) { return P; }
19561957

19571958
} // end namespace llvm
1959+
}} // namespace swift::runtime
19581960

19591961
#endif // LLVM_ADT_STLEXTRAS_H

stdlib/include/llvm/ADT/SmallPtrSet.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <iterator>
2727
#include <utility>
2828

29+
inline namespace __swift { inline namespace __runtime {
2930
namespace llvm {
3031

3132
/// SmallPtrSetImplBase - This is the common code shared among all the
@@ -491,6 +492,7 @@ class SmallPtrSet : public SmallPtrSetImpl<PtrType> {
491492
};
492493

493494
} // end namespace llvm
495+
}} // namespace swift::runtime
494496

495497
namespace std {
496498

stdlib/include/llvm/ADT/SmallSet.h

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <type_traits>
2626
#include <utility>
2727

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

3031
/// SmallSetIterator - This class implements a const_iterator for SmallSet by
@@ -274,5 +275,6 @@ bool operator!=(const SmallSet<T, LN, C> &LHS, const SmallSet<T, RN, C> &RHS) {
274275
}
275276

276277
} // end namespace llvm
278+
}} // namespace swift::runtime
277279

278280
#endif // LLVM_ADT_SMALLSET_H

stdlib/include/llvm/ADT/SmallString.h

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/StringRef.h"
1818
#include <cstddef>
1919

20+
inline namespace __swift { inline namespace __runtime {
2021
namespace llvm {
2122

2223
/// SmallString - A SmallString is just a SmallVector with methods and accessors
@@ -296,5 +297,6 @@ class SmallString : public SmallVector<char, InternalLen> {
296297
};
297298

298299
} // end namespace llvm
300+
}} // swift::runtime
299301

300302
#endif // LLVM_ADT_SMALLSTRING_H

stdlib/include/llvm/ADT/SmallVector.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <type_traits>
3434
#include <utility>
3535

36+
inline namespace __swift { inline namespace __runtime {
3637
namespace llvm {
3738

3839
/// This is all the stuff common to all SmallVectors.
@@ -966,20 +967,23 @@ to_vector(R &&Range) {
966967
}
967968

968969
} // end namespace llvm
970+
}} // namespace swift::runtime
969971

970972
namespace std {
971973

972974
/// Implement std::swap in terms of SmallVector swap.
973975
template<typename T>
974976
inline void
975-
swap(llvm::SmallVectorImpl<T> &LHS, llvm::SmallVectorImpl<T> &RHS) {
977+
swap(__swift::__runtime::llvm::SmallVectorImpl<T> &LHS,
978+
__swift::__runtime::llvm::SmallVectorImpl<T> &RHS) {
976979
LHS.swap(RHS);
977980
}
978981

979982
/// Implement std::swap in terms of SmallVector swap.
980983
template<typename T, unsigned N>
981984
inline void
982-
swap(llvm::SmallVector<T, N> &LHS, llvm::SmallVector<T, N> &RHS) {
985+
swap(__swift::__runtime::llvm::SmallVector<T, N> &LHS,
986+
__swift::__runtime::llvm::SmallVector<T, N> &RHS) {
983987
LHS.swap(RHS);
984988
}
985989

stdlib/include/llvm/ADT/StringExtras.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <string>
2727
#include <utility>
2828

29+
inline namespace __swift { inline namespace __runtime {
2930
namespace llvm {
3031

3132
template<typename T> class SmallVectorImpl;
@@ -417,5 +418,6 @@ inline std::string join_items(Sep Separator, Args &&... Items) {
417418
}
418419

419420
} // end namespace llvm
421+
}} // namespace swift::runtime
420422

421423
#endif // LLVM_ADT_STRINGEXTRAS_H

stdlib/include/llvm/ADT/StringMap.h

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <initializer_list>
2020
#include <iterator>
2121

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

2425
template <typename ValueTy> class StringMapConstIterator;
@@ -451,5 +452,6 @@ class StringMapKeyIterator
451452
};
452453

453454
} // end namespace llvm
455+
}} // namespace swift::runtime
454456

455457
#endif // LLVM_ADT_STRINGMAP_H

0 commit comments

Comments
 (0)