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

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 16:22:38 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Naveen Seth Hanig (naveen-seth)

<details>
<summary>Changes</summary>

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.

---
Full diff: https://github.com/llvm/llvm-project/pull/152811.diff


1 Files Affected:

- (modified) llvm/include/llvm/Support/GraphWriter.h (+2) 


``````````diff
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 "

``````````

</details>


https://github.com/llvm/llvm-project/pull/152811


More information about the llvm-commits mailing list