[llvm] [Support] Ensure complete type DelimitedScope (PR #127459)
Jonas Hahnfeld via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 01:04:18 PST 2025
https://github.com/hahnjo created https://github.com/llvm/llvm-project/pull/127459
`JSONScopedPrinter` has a `std::unique_ptr<DelimitedScope>` member and defaulted constructor argument, so it needs a complete type. This resolves one of the many build errors with C++23 using Clang.
>From d4ce3317c55aa7aa914d582d27b692b011bcfaa2 Mon Sep 17 00:00:00 2001
From: Jonas Hahnfeld <hahnjo at hahnjo.de>
Date: Mon, 17 Feb 2025 09:59:34 +0100
Subject: [PATCH] [Support] Ensure complete type DelimitedScope
JSONScopedPrinter has a std::unique_ptr<DelimitedScope> member and
defaulted constructor argument, so it needs a complete type. This
resolves one of the many build errors with C++23 using Clang.
---
llvm/include/llvm/Support/ScopedPrinter.h | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h
index 419ab97366796..506b40a09ed78 100644
--- a/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/llvm/include/llvm/Support/ScopedPrinter.h
@@ -539,7 +539,13 @@ ScopedPrinter::printHex<support::ulittle16_t>(StringRef Label,
startLine() << Label << ": " << hex(Value) << "\n";
}
-struct DelimitedScope;
+struct DelimitedScope {
+ DelimitedScope(ScopedPrinter &W) : W(&W) {}
+ DelimitedScope() : W(nullptr) {}
+ virtual ~DelimitedScope() = default;
+ virtual void setPrinter(ScopedPrinter &W) = 0;
+ ScopedPrinter *W;
+};
class JSONScopedPrinter : public ScopedPrinter {
private:
@@ -838,14 +844,6 @@ class JSONScopedPrinter : public ScopedPrinter {
}
};
-struct DelimitedScope {
- DelimitedScope(ScopedPrinter &W) : W(&W) {}
- DelimitedScope() : W(nullptr) {}
- virtual ~DelimitedScope() = default;
- virtual void setPrinter(ScopedPrinter &W) = 0;
- ScopedPrinter *W;
-};
-
struct DictScope : DelimitedScope {
explicit DictScope() = default;
explicit DictScope(ScopedPrinter &W) : DelimitedScope(W) { W.objectBegin(); }
More information about the llvm-commits
mailing list