Skip to content

Conversation

@vitalybuka
Copy link
Collaborator

Will help in future patches.

@llvmbot
Copy link
Member

llvmbot commented Nov 10, 2025

@llvm/pr-subscribers-llvm-support

Author: Vitaly Buka (vitalybuka)

Changes

Will help in future patches.


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

1 Files Affected:

  • (modified) llvm/lib/Support/SpecialCaseList.cpp (+7-5)
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp
index 395a55d75acd4..beec8b8ef0d5b 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -274,11 +274,12 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
 
   bool RemoveDotSlash = Version > 2;
 
-  Section *CurrentSection;
-  if (auto Err = addSection("*", FileIdx, 1, true).moveInto(CurrentSection)) {
+  auto ErrOrSection = addSection("*", FileIdx, 1, true);
+  if (auto Err = ErrOrSection.takeError()) {
     Error = toString(std::move(Err));
     return false;
   }
+  Section *CurrentSection = ErrOrSection.get();
 
   // This is the current list of prefixes for all existing users matching file
   // path. We may need parametrization in constructor in future.
@@ -300,12 +301,13 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
         return false;
       }
 
-      if (auto Err = addSection(Line.drop_front().drop_back(), FileIdx, LineNo,
-                                UseGlobs)
-                         .moveInto(CurrentSection)) {
+      auto ErrOrSection =
+          addSection(Line.drop_front().drop_back(), FileIdx, LineNo, UseGlobs);
+      if (auto Err = ErrOrSection.takeError()) {
         Error = toString(std::move(Err));
         return false;
       }
+      CurrentSection = ErrOrSection.get();
       continue;
     }
 

vitalybuka added a commit to vitalybuka/llvm-project that referenced this pull request Nov 10, 2025
Will help in future patches.

Pull Request: llvm#167277
Created using spr 1.3.7

[skip ci]
Created using spr 1.3.7
@vitalybuka vitalybuka requested a review from Copilot November 10, 2025 22:17
@vitalybuka vitalybuka changed the base branch from users/vitalybuka/spr/main.nfcspecialcaselist-refactor-error-handling to main November 10, 2025 22:17
Copilot finished reviewing on behalf of vitalybuka November 10, 2025 22:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors error handling in SpecialCaseList::parse() by replacing calls to moveInto() with a two-step approach: first calling takeError() to check for errors, then calling get() to retrieve the value. However, this refactoring introduces a subtle but critical API misuse issue.

  • Replaces moveInto() pattern with takeError() followed by get()
  • Applied to two instances of addSection() calls in the parsing logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vitalybuka vitalybuka enabled auto-merge (squash) November 10, 2025 22:42
@vitalybuka vitalybuka merged commit da996a3 into main Nov 10, 2025
18 of 19 checks passed
@vitalybuka vitalybuka deleted the users/vitalybuka/spr/nfcspecialcaselist-refactor-error-handling branch November 10, 2025 22:43
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