Merge commit 'a31edf53d0580efe47f4e9ef89dccc4429c056e8' into import-as-member

This commit is contained in:
Michael Ilseman
2016-03-23 13:05:57 -07:00
6536 changed files with 81412 additions and 56907 deletions

View File

@@ -45,6 +45,9 @@ namespace swift {
#define DEFER_CONCAT_IMPL(x, y) x##y
#define DEFER_MACRO_CONCAT(x, y) DEFER_CONCAT_IMPL(x, y)
#define defer_impl \
auto DEFER_MACRO_CONCAT(defer_func, __COUNTER__) = \
::swift::detail::DeferTask() + [&]()
/// This macro is used to register a function / lambda to be run on exit from a
/// scope. Its typical use looks like:
@@ -53,9 +56,6 @@ namespace swift {
/// stuff
/// };
///
#define defer \
auto DEFER_MACRO_CONCAT(defer_func, __COUNTER__) = \
::swift::detail::DeferTask() + [&]()
#define defer defer_impl
#endif

View File

@@ -134,6 +134,46 @@ public:
assert(Other->ParentFactory.get() == ParentFactory.get());
return ParentFactory.get()->merge(this, Other);
}
bool hasEmptyIntersection(const ImmutablePointerSet<T> *Other) const {
// If we are empty or Other is empty, then there are automatically no
// elements that could be in the intersection. Return true.
if (empty() || Other->empty())
return true;
// Ok, at this point we know that both self and Other are non-empty. They
// can only have a non-empty intersection if they have elements in common.
// Sadly it seems the STL does not have such a predicate that is
// non-constructive in the algorithm library, so we implement it ourselves.
auto LHSI = begin();
auto LHSE = end();
auto RHSI = Other->begin();
auto RHSE = Other->end();
// Our implementation is to perform a sorted merge like traversal of both
// lists, always advancing the iterator with a smaller value. If we ever hit
// an equality in between our iterators, we have a non-empty intersection.
//
// Until either of our iterators hits the end of our target arrays...
while (LHSI != LHSE && RHSI != RHSE) {
// If LHSI is equivalent to RHSI, then we have a non-empty intersection...
// Early exit.
if (*LHSI == *RHSI)
return false;
// Otherwise, if *LHSI is less than *RHSI, advance LHSI.
if (*LHSI < *RHSI) {
++LHSI;
continue;
}
// Otherwise, We know that *RHSI < *LHSI. Advance RHSI.
++RHSI;
}
// We did not have any overlapping intersection.
return true;
}
};
template <typename T> class ImmutablePointerSetFactory {
@@ -159,6 +199,8 @@ public:
// statically.
static PtrSet *getEmptySet() { return &EmptyPtrSet; }
void clear() { Set.clear(); }
/// Given a sorted and uniqued list \p Array, return the ImmutablePointerSet
/// containing Array. Asserts if \p Array is not sorted and uniqued.
PtrSet *get(ArrayRef<PtrTy> Array) {

View File

@@ -151,7 +151,7 @@ namespace swift {
/// places elsewhere in the compiler that specifically reference
/// Objective-C entities whose names are affected by
/// omit-needless-words.
bool OmitNeedlessWords = false;
bool OmitNeedlessWords = true;
/// Whether to use the import as member inference system
///

View File

@@ -0,0 +1,17 @@
***************
*** 148,154 ****
/// places elsewhere in the compiler that specifically reference
/// Objective-C entities whose names are affected by
/// omit-needless-words.
- bool OmitNeedlessWords = false;
/// Enable the Swift 3 migration via Fix-Its.
bool Swift3Migration = false;
--- 148,154 ----
/// places elsewhere in the compiler that specifically reference
/// Objective-C entities whose names are affected by
/// omit-needless-words.
+ bool OmitNeedlessWords = true;
/// Enable the Swift 3 migration via Fix-Its.
bool Swift3Migration = false;

View File

@@ -270,15 +270,29 @@ template <class T> EnumeratorRange<T> enumerate(T Begin, T End) {
/// An adaptor of std::none_of for ranges.
template <class Range, class Predicate>
inline
bool
none_of(Range R, Predicate P) {
return std::none_of(R.begin(), R.end(), P);
inline bool none_of(const Range &R, Predicate &&P) {
return std::none_of(R.begin(), R.end(), std::forward<Predicate>(P));
}
/// An adaptor of std::count for ranges.
///
/// We use std::result_of on Range::begin since llvm::iterator_range does not
/// have a public typedef set to what is the underlying iterator.
//typename std::iterator_traits<decltype(&Range::begin())>::difference_type
template <class Range, class Value>
inline auto count(const Range &R, Value V)
-> typename std::iterator_traits<decltype(R.begin())>::difference_type {
return std::count(R.begin(), R.end(), V);
}
/// An adaptor of std::count_if for ranges.
///
/// We use std::result_of on Range::begin since llvm::iterator_range does not
/// have a public typedef set to what is the underlying iterator.
template <class Range, class Predicate>
inline unsigned count_if(Range R, Predicate P) {
return std::count_if(R.begin(), R.end(), P);
inline auto count_if(const Range &R, Predicate &&P)
-> typename std::iterator_traits<decltype(R.begin())>::difference_type {
return std::count_if(R.begin(), R.end(), std::forward<Predicate>(P));
}
} // namespace swift