[llvm] [Support] Fix CRTP for GraphWriter (NFC) (PR #152811)

Naveen Seth Hanig via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 16:22:08 PDT 2025


https://github.com/naveen-seth created https://github.com/llvm/llvm-project/pull/152811

Commit 474bbc1 forgot to change `GraphWriterBase`'s members from private to protected.
Because of this, `GraphWriter` can't be properly partially specialized using CRTP.
This commit corrects that, allowing `GraphWriterBase` to be partially specialized using CRTP as intended.

>From b4bd1a971179e7c954d39df8c2f79286e457c30c Mon Sep 17 00:00:00 2001
From: Naveen Seth Hanig <naveen.hanig at outlook.com>
Date: Sat, 9 Aug 2025 01:06:04 +0200
Subject: [PATCH] [Support] Fix CRTP for GraphWriter (NFC)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Commit 474bbc1 forgot to change GraphWriterBase's members from private
to protected. Because of this, GraphWriter cant’t be properly
partially specialized using CRTP.
This commit corrects that, allowing GraphWriterBase to be partially
specialized using CRTP as intended.
---
 llvm/include/llvm/Support/GraphWriter.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h
index af2e5016298e6..58e5b59751b67 100644
--- a/llvm/include/llvm/Support/GraphWriter.h
+++ b/llvm/include/llvm/Support/GraphWriter.h
@@ -62,6 +62,7 @@ LLVM_ABI bool DisplayGraph(StringRef Filename, bool wait = true,
                            GraphProgram::Name program = GraphProgram::DOT);
 
 template <typename GraphType, typename Derived> class GraphWriterBase {
+protected:
   raw_ostream &O;
   const GraphType &G;
   bool RenderUsingHTML = false;
@@ -73,6 +74,7 @@ template <typename GraphType, typename Derived> class GraphWriterBase {
   using child_iterator = typename GTraits::ChildIteratorType;
   DOTTraits DTraits;
 
+private:
   static_assert(std::is_pointer_v<NodeRef>,
                 "FIXME: Currently GraphWriterBase requires the NodeRef type to "
                 "be a pointer.\nThe pointer usage should be moved to "



More information about the llvm-commits mailing list