Skip to content

[NFC][YAML] Add IO::error() #123475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

vitalybuka
Copy link
Collaborator

@vitalybuka vitalybuka commented Jan 18, 2025

For #123280

@llvmbot
Copy link
Member

llvmbot commented Jan 18, 2025

@llvm/pr-subscribers-llvm-support

Author: Vitaly Buka (vitalybuka)

Changes

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

2 Files Affected:

  • (modified) llvm/include/llvm/Support/YAMLTraits.h (+3-1)
  • (modified) llvm/lib/Support/YAMLTraits.cpp (+2)
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

vitalybuka added a commit that referenced this pull request Jan 21, 2025
@vitalybuka vitalybuka force-pushed the users/vitalybuka/spr/nfcyaml-add-ioerror branch from 487784c to e696bc4 Compare January 21, 2025 08:34
@vitalybuka vitalybuka force-pushed the users/vitalybuka/spr/nfcyaml-add-ioerror branch from 0a895fd to c6e72c4 Compare January 22, 2025 19:19
Copy link
Collaborator

@jh7370 jh7370 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@vitalybuka vitalybuka merged commit 4f26edd into main Jan 23, 2025
10 of 11 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/nfcyaml-add-ioerror branch January 23, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants