Update prebuilt Clang to match Android kernel.
Bug: 132428451
Change-Id: I8f6e2cb23f381fc0c02ddea99b867e58e925e5be
diff --git a/linux-x64/clang/include/llvm/ADT/DenseMap.h b/linux-x64/clang/include/llvm/ADT/DenseMap.h
index 380f1db..e7cd370 100644
--- a/linux-x64/clang/include/llvm/ADT/DenseMap.h
+++ b/linux-x64/clang/include/llvm/ADT/DenseMap.h
@@ -1,9 +1,8 @@
//===- llvm/ADT/DenseMap.h - Dense probed hash table ------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -25,6 +24,7 @@
#include <cassert>
#include <cstddef>
#include <cstring>
+#include <initializer_list>
#include <iterator>
#include <new>
#include <type_traits>
@@ -38,6 +38,34 @@
// implementation without requiring two members.
template <typename KeyT, typename ValueT>
struct DenseMapPair : public std::pair<KeyT, ValueT> {
+
+ // FIXME: Switch to inheriting constructors when we drop support for older
+ // clang versions.
+ // NOTE: This default constructor is declared with '{}' rather than
+ // '= default' to work around a separate bug in clang-3.8. This can
+ // also go when we switch to inheriting constructors.
+ DenseMapPair() {}
+
+ DenseMapPair(const KeyT &Key, const ValueT &Value)
+ : std::pair<KeyT, ValueT>(Key, Value) {}
+
+ DenseMapPair(KeyT &&Key, ValueT &&Value)
+ : std::pair<KeyT, ValueT>(std::move(Key), std::move(Value)) {}
+
+ template <typename AltKeyT, typename AltValueT>
+ DenseMapPair(AltKeyT &&AltKey, AltValueT &&AltValue,
+ typename std::enable_if<
+ std::is_convertible<AltKeyT, KeyT>::value &&
+ std::is_convertible<AltValueT, ValueT>::value>::type * = 0)
+ : std::pair<KeyT, ValueT>(std::forward<AltKeyT>(AltKey),
+ std::forward<AltValueT>(AltValue)) {}
+
+ template <typename AltPairT>
+ DenseMapPair(AltPairT &&AltPair,
+ typename std::enable_if<std::is_convertible<
+ AltPairT, std::pair<KeyT, ValueT>>::value>::type * = 0)
+ : std::pair<KeyT, ValueT>(std::forward<AltPairT>(AltPair)) {}
+
KeyT &getFirst() { return std::pair<KeyT, ValueT>::first; }
const KeyT &getFirst() const { return std::pair<KeyT, ValueT>::first; }
ValueT &getSecond() { return std::pair<KeyT, ValueT>::second; }
@@ -46,9 +74,10 @@
} // end namespace detail
-template <
- typename KeyT, typename ValueT, typename KeyInfoT = DenseMapInfo<KeyT>,
- typename Bucket = detail::DenseMapPair<KeyT, ValueT>, bool IsConst = false>
+template <typename KeyT, typename ValueT,
+ typename KeyInfoT = DenseMapInfo<KeyT>,
+ typename Bucket = llvm::detail::DenseMapPair<KeyT, ValueT>,
+ bool IsConst = false>
class DenseMapIterator;
template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,
@@ -116,7 +145,8 @@
}
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
- if (isPodLike<KeyT>::value && isPodLike<ValueT>::value) {
+ if (is_trivially_copyable<KeyT>::value &&
+ is_trivially_copyable<ValueT>::value) {
// Use a simpler loop when these are trivial types.
for (BucketT *P = getBuckets(), *E = getBucketsEnd(); P != E; ++P)
P->getFirst() = EmptyKey;
@@ -392,7 +422,8 @@
setNumEntries(other.getNumEntries());
setNumTombstones(other.getNumTombstones());
- if (isPodLike<KeyT>::value && isPodLike<ValueT>::value)
+ if (is_trivially_copyable<KeyT>::value &&
+ is_trivially_copyable<ValueT>::value)
memcpy(reinterpret_cast<void *>(getBuckets()), other.getBuckets(),
getNumBuckets() * sizeof(BucketT));
else
@@ -639,9 +670,43 @@
}
};
+/// Equality comparison for DenseMap.
+///
+/// Iterates over elements of LHS confirming that each (key, value) pair in LHS
+/// is also in RHS, and that no additional pairs are in RHS.
+/// Equivalent to N calls to RHS.find and N value comparisons. Amortized
+/// complexity is linear, worst case is O(N^2) (if every hash collides).
+template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,
+ typename BucketT>
+bool operator==(
+ const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &LHS,
+ const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &RHS) {
+ if (LHS.size() != RHS.size())
+ return false;
+
+ for (auto &KV : LHS) {
+ auto I = RHS.find(KV.first);
+ if (I == RHS.end() || I->second != KV.second)
+ return false;
+ }
+
+ return true;
+}
+
+/// Inequality comparison for DenseMap.
+///
+/// Equivalent to !(LHS == RHS). See operator== for performance notes.
+template <typename DerivedT, typename KeyT, typename ValueT, typename KeyInfoT,
+ typename BucketT>
+bool operator!=(
+ const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &LHS,
+ const DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT> &RHS) {
+ return !(LHS == RHS);
+}
+
template <typename KeyT, typename ValueT,
typename KeyInfoT = DenseMapInfo<KeyT>,
- typename BucketT = detail::DenseMapPair<KeyT, ValueT>>
+ typename BucketT = llvm::detail::DenseMapPair<KeyT, ValueT>>
class DenseMap : public DenseMapBase<DenseMap<KeyT, ValueT, KeyInfoT, BucketT>,
KeyT, ValueT, KeyInfoT, BucketT> {
friend class DenseMapBase<DenseMap, KeyT, ValueT, KeyInfoT, BucketT>;
@@ -676,6 +741,11 @@
this->insert(I, E);
}
+ DenseMap(std::initializer_list<typename BaseT::value_type> Vals) {
+ init(Vals.size());
+ this->insert(Vals.begin(), Vals.end());
+ }
+
~DenseMap() {
this->destroyAll();
operator delete(Buckets);
@@ -798,7 +868,7 @@
template <typename KeyT, typename ValueT, unsigned InlineBuckets = 4,
typename KeyInfoT = DenseMapInfo<KeyT>,
- typename BucketT = detail::DenseMapPair<KeyT, ValueT>>
+ typename BucketT = llvm::detail::DenseMapPair<KeyT, ValueT>>
class SmallDenseMap
: public DenseMapBase<
SmallDenseMap<KeyT, ValueT, InlineBuckets, KeyInfoT, BucketT>, KeyT,