Skip to content

Commit 64e46af

Browse files
committed
[LLVMSupport] Drop remaining dependencies on APSInt.h, Error.h, DataTypes.h and STLForwardCompat.h
Most cases can drop the #includes without any changes, in some cases there are straighforward replacements (climits, cstdint). For STLForwardCompat.h, we need to bring in parts of STLForwardCompat.h from llvm-project.
1 parent 6a2dd8a commit 64e46af

File tree

6 files changed

+42
-6
lines changed

6 files changed

+42
-6
lines changed

include/swift/AST/LayoutConstraintKind.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
#include "llvm/Support/DataTypes.h"
17+
#include <cstdint>
1818

1919
#ifndef SWIFT_LAYOUT_CONSTRAINTKIND_H
2020
#define SWIFT_LAYOUT_CONSTRAINTKIND_H

stdlib/include/llvm/ADT/Optional.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "llvm/ADT/Hashing.h"
1919
#include "llvm/ADT/None.h"
20-
#include "llvm/ADT/STLForwardCompat.h"
2120
#include "llvm/Support/Compiler.h"
2221
#include "llvm/Support/type_traits.h"
2322
#include <cassert>
@@ -28,6 +27,19 @@
2827
inline namespace __swift { inline namespace __runtime {
2928
namespace llvm {
3029

30+
struct in_place_t // NOLINT(readability-identifier-naming)
31+
{
32+
explicit in_place_t() = default;
33+
};
34+
/// \warning This must not be odr-used, as it cannot be made \c inline in C++14.
35+
constexpr in_place_t in_place; // NOLINT(readability-identifier-naming)
36+
37+
template <typename T>
38+
struct in_place_type_t // NOLINT(readability-identifier-naming)
39+
{
40+
explicit in_place_type_t() = default;
41+
};
42+
3143
class raw_ostream;
3244

3345
namespace optional_detail {

stdlib/include/llvm/ADT/STLExtras.h

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#define LLVM_ADT_STLEXTRAS_H
1818

1919
#include "llvm/ADT/Optional.h"
20-
#include "llvm/ADT/STLForwardCompat.h"
2120
#include "llvm/ADT/iterator.h"
2221
#include "llvm/ADT/iterator_range.h"
2322
#include "llvm/Support/ErrorHandling.h"
@@ -42,6 +41,32 @@
4241
inline namespace __swift { inline namespace __runtime {
4342
namespace llvm {
4443

44+
template <typename...>
45+
struct conjunction // NOLINT(readability-identifier-naming)
46+
: std::true_type {};
47+
template <typename B1> struct conjunction<B1> : B1 {};
48+
template <typename B1, typename... Bn>
49+
struct conjunction<B1, Bn...>
50+
: std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
51+
52+
template <typename...>
53+
struct disjunction // NOLINT(readability-identifier-naming)
54+
: std::false_type {};
55+
template <typename B1> struct disjunction<B1> : B1 {};
56+
template <typename B1, typename... Bn>
57+
struct disjunction<B1, Bn...>
58+
: std::conditional<bool(B1::value), B1, disjunction<Bn...>>::type {};
59+
60+
template <typename T>
61+
struct remove_cvref // NOLINT(readability-identifier-naming)
62+
{
63+
using type = std::remove_cv_t<std::remove_reference_t<T>>;
64+
};
65+
66+
template <typename T>
67+
using remove_cvref_t // NOLINT(readability-identifier-naming)
68+
= typename llvm::remove_cvref<T>::type;
69+
4570
// Only used by compiler if both template types are the same. Useful when
4671
// using SFINAE to test for the existence of member functions.
4772
template <typename T, T> struct SameType;

stdlib/include/llvm/ADT/StringExtras.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#ifndef LLVM_ADT_STRINGEXTRAS_H
1414
#define LLVM_ADT_STRINGEXTRAS_H
1515

16-
#include "llvm/ADT/APSInt.h"
1716
#include "llvm/ADT/ArrayRef.h"
1817
#include "llvm/ADT/SmallString.h"
1918
#include "llvm/ADT/StringRef.h"

stdlib/include/llvm/Support/raw_ostream.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#include "llvm/ADT/SmallVector.h"
1717
#include "llvm/ADT/StringRef.h"
18-
#include "llvm/Support/DataTypes.h"
1918
#include <cassert>
2019
#include <chrono>
2120
#include <cstddef>

stdlib/public/LLVMSupport/StringRef.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "llvm/ADT/StringExtras.h"
910
#include "llvm/ADT/StringRef.h"
1011
#include "llvm/ADT/Hashing.h"
11-
#include "llvm/Support/Error.h"
1212
#include <bitset>
13+
#include <climits>
1314

1415
using namespace llvm;
1516

0 commit comments

Comments
 (0)