Skip to content

Commit 5e080a7

Browse files
authored
Fix build when compiling against libc++ (#5284)
When using libc++, the build fails with errors like: error: incomplete type 'clang::DeclContext::udir_iterator' used in type trait expression : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; ^ note: while substituting deduced template arguments into function template 'iterator_adaptor_base' [with U = const llvm::iterator_adaptor_base<clang::DeclContext::udir_iterator, clang::DeclContextLookupResult::iterator, std::random_access_iterator_tag, clang::UsingDirectiveDecl *> &] class iterator_adaptor_base This was fixed in upstream LLVM in this CL: llvm/llvm-project@e78e32a (also see original review: https://reviews.llvm.org/D22951#change-zKJSAlLXXy11) Unfortunately, the CL does not explain why this change was made, so I can only assume that it was failing a libc++ build as well. I also added the static_assert that was later added in this CL: llvm/llvm-project@0aecae3 This restores the build failure that would occur if U is not a base of DerivedT.
1 parent 66f8c6d commit 5e080a7

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

include/llvm/ADT/iterator.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,12 @@ class iterator_adaptor_base
152152

153153
iterator_adaptor_base() = default;
154154

155-
template <typename U>
156-
explicit iterator_adaptor_base(
157-
U &&u,
158-
typename std::enable_if<
159-
!std::is_base_of<typename std::remove_cv<
160-
typename std::remove_reference<U>::type>::type,
161-
DerivedT>::value,
162-
int>::type = 0)
163-
: I(std::forward<U &&>(u)) {}
155+
// HLSL Change Begins: Fix libc++ build
156+
explicit iterator_adaptor_base(WrappedIteratorT u) : I(std::move(u)) {
157+
static_assert(std::is_base_of<iterator_adaptor_base, DerivedT>::value,
158+
"Must pass the derived type to this template!");
159+
}
160+
// HLSL Change Ends
164161

165162
const WrappedIteratorT &wrapped() const { return I; }
166163

0 commit comments

Comments
 (0)