[llvm] [ADT] Fix MSVC build after iterator C++20 fix (PR #173495)

Jorn Tuyls via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 24 06:20:52 PST 2025


https://github.com/jtuyls updated https://github.com/llvm/llvm-project/pull/173495

>From ddcb06bc6c6fdfc16d17983a31dd583252e403a6 Mon Sep 17 00:00:00 2001
From: Jorn Tuyls <jorn.tuyls at gmail.com>
Date: Wed, 24 Dec 2025 05:21:20 -0600
Subject: [PATCH] [ADT] Fix MSVC build after iterator C++20 fix

---
 llvm/include/llvm/ADT/iterator.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llvm/include/llvm/ADT/iterator.h b/llvm/include/llvm/ADT/iterator.h
index c0495e24893fb..5d129ea9f10df 100644
--- a/llvm/include/llvm/ADT/iterator.h
+++ b/llvm/include/llvm/ADT/iterator.h
@@ -85,7 +85,9 @@ class iterator_facade_base {
   using pointer = PointerT;
   using reference = ReferenceT;
 
-protected:
+  // Note: These were previously protected, but MSVC has trouble with SFINAE
+  // accessing protected members in derived class templates (specifically in
+  // iterator_adaptor_base::operator-). Making them public fixes the build.
   enum {
     IsRandomAccess = std::is_base_of<std::random_access_iterator_tag,
                                      IteratorCategoryT>::value,
@@ -93,6 +95,7 @@ class iterator_facade_base {
                                       IteratorCategoryT>::value,
   };
 
+protected:
   /// A proxy object for computing a reference via indirecting a copy of an
   /// iterator. This is used in APIs which need to produce a reference via
   /// indirection but for which the iterator object might be a temporary. The



More information about the llvm-commits mailing list