[llvm] [NFC][YAML] Add `IO::error()` (PR #123475)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 22 11:17:58 PST 2025
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/123475
>From e696bc48465e52ba4f98bb6c3edfb132139fa3c2 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 18 Jan 2025 12:23:12 -0800
Subject: [PATCH 1/3] [NFC][YAML] Add `IO::error()`
Pull Request: https://github.com/llvm/llvm-project/pull/123475
---
llvm/include/llvm/Support/YAMLTraits.h | 4 +++-
llvm/lib/Support/YAMLTraits.cpp | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index eca26e90845bf6..e707a445012b51 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -819,6 +819,7 @@ class IO {
virtual NodeKind getNodeKind() = 0;
virtual void setError(const Twine &) = 0;
+ virtual std::error_code error() = 0;
virtual void setAllowUnknownKeys(bool Allow);
template <typename T>
@@ -1448,7 +1449,7 @@ class Input : public IO {
~Input() override;
// Check if there was an syntax or semantic error during parsing.
- std::error_code error();
+ std::error_code error() override;
private:
bool outputting() const override;
@@ -1631,6 +1632,7 @@ class Output : public IO {
void scalarTag(std::string &) override;
NodeKind getNodeKind() override;
void setError(const Twine &message) override;
+ std::error_code error() override;
bool canElideEmptySequence() override;
// These are only used by operator<<. They could be private
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index f326422138488c..28642e004c4f43 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -750,6 +750,8 @@ void Output::scalarTag(std::string &Tag) {
void Output::setError(const Twine &message) {
}
+std::error_code Output::error() { return {}; }
+
bool Output::canElideEmptySequence() {
// Normally, with an optional key/value where the value is an empty sequence,
// the whole key/value can be not written. But, that produces wrong yaml
>From 6b200014fc7ce860343b8c180a6f9af876c71bce Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Tue, 21 Jan 2025 09:05:44 -0800
Subject: [PATCH 2/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20introduced=20through=20rebase?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.4
[skip ci]
---
llvm/include/llvm/Support/YAMLTraits.h | 4 +---
llvm/lib/Support/YAMLTraits.cpp | 2 --
2 files changed, 1 insertion(+), 5 deletions(-)
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index e707a445012b51..eca26e90845bf6 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -819,7 +819,6 @@ class IO {
virtual NodeKind getNodeKind() = 0;
virtual void setError(const Twine &) = 0;
- virtual std::error_code error() = 0;
virtual void setAllowUnknownKeys(bool Allow);
template <typename T>
@@ -1449,7 +1448,7 @@ class Input : public IO {
~Input() override;
// Check if there was an syntax or semantic error during parsing.
- std::error_code error() override;
+ std::error_code error();
private:
bool outputting() const override;
@@ -1632,7 +1631,6 @@ class Output : public IO {
void scalarTag(std::string &) override;
NodeKind getNodeKind() override;
void setError(const Twine &message) override;
- std::error_code error() override;
bool canElideEmptySequence() override;
// These are only used by operator<<. They could be private
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index 28642e004c4f43..f326422138488c 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -750,8 +750,6 @@ void Output::scalarTag(std::string &Tag) {
void Output::setError(const Twine &message) {
}
-std::error_code Output::error() { return {}; }
-
bool Output::canElideEmptySequence() {
// Normally, with an optional key/value where the value is an empty sequence,
// the whole key/value can be not written. But, that produces wrong yaml
>From 776869490e6aff852aa5c57e9364102a4116f7d8 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Tue, 21 Jan 2025 09:18:37 -0800
Subject: [PATCH 3/3] test
Created using spr 1.3.4
---
llvm/include/llvm/Support/YAMLTraits.h | 4 +++-
llvm/lib/Support/YAMLTraits.cpp | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h
index eca26e90845bf6..e707a445012b51 100644
--- a/llvm/include/llvm/Support/YAMLTraits.h
+++ b/llvm/include/llvm/Support/YAMLTraits.h
@@ -819,6 +819,7 @@ class IO {
virtual NodeKind getNodeKind() = 0;
virtual void setError(const Twine &) = 0;
+ virtual std::error_code error() = 0;
virtual void setAllowUnknownKeys(bool Allow);
template <typename T>
@@ -1448,7 +1449,7 @@ class Input : public IO {
~Input() override;
// Check if there was an syntax or semantic error during parsing.
- std::error_code error();
+ std::error_code error() override;
private:
bool outputting() const override;
@@ -1631,6 +1632,7 @@ class Output : public IO {
void scalarTag(std::string &) override;
NodeKind getNodeKind() override;
void setError(const Twine &message) override;
+ std::error_code error() override;
bool canElideEmptySequence() override;
// These are only used by operator<<. They could be private
diff --git a/llvm/lib/Support/YAMLTraits.cpp b/llvm/lib/Support/YAMLTraits.cpp
index f326422138488c..28642e004c4f43 100644
--- a/llvm/lib/Support/YAMLTraits.cpp
+++ b/llvm/lib/Support/YAMLTraits.cpp
@@ -750,6 +750,8 @@ void Output::scalarTag(std::string &Tag) {
void Output::setError(const Twine &message) {
}
+std::error_code Output::error() { return {}; }
+
bool Output::canElideEmptySequence() {
// Normally, with an optional key/value where the value is an empty sequence,
// the whole key/value can be not written. But, that produces wrong yaml
More information about the llvm-commits
mailing list