Skip to content

[BOLT][DWARF][NFC] Update Die to not use std::optional #97844

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 2 commits into from
Jul 9, 2024

Conversation

sayhaan
Copy link
Member

@sayhaan sayhaan commented Jul 5, 2024

Updates initialization to remove unnecessary use of std::optional.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: https://phabricator.intern.facebook.com/D59399659
Copy link

github-actions bot commented Jul 5, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@sayhaan sayhaan marked this pull request as ready for review July 5, 2024 17:49
@llvmbot llvmbot added the BOLT label Jul 5, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 5, 2024

@llvm/pr-subscribers-bolt

Author: Sayhaan Siddiqui (sayhaan)

Changes

Updates initialization to remove unnecessary use of std::optional.


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

1 Files Affected:

  • (modified) bolt/lib/Rewrite/DWARFRewriter.cpp (+4-5)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 1f426d0adfc61..330865e9733bb 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -1638,14 +1638,13 @@ void DWARFRewriter::finalizeCompileUnits(DIEBuilder &DIEBlder,
            "RangesWriter does not exist for DWOId");
     std::unique_ptr<DebugRangesSectionWriter> &LegacyRangesWriter =
         RangesWriterIterator->second;
-    std::optional<DIE *> Die = LegacyRangesWriter->getDie();
-    if (!Die || !Die.value())
+    DIE *Die = LegacyRangesWriter->getDie();
+    if (!Die)
       continue;
-    DIEValue DvalGNUBase =
-        Die.value()->findAttribute(dwarf::DW_AT_GNU_ranges_base);
+    DIEValue DvalGNUBase = Die->findAttribute(dwarf::DW_AT_GNU_ranges_base);
     assert(DvalGNUBase && "GNU_ranges_base attribute does not exist for DWOId");
     DIEBlder.replaceValue(
-        Die.value(), dwarf::DW_AT_GNU_ranges_base, DvalGNUBase.getForm(),
+        Die, dwarf::DW_AT_GNU_ranges_base, DvalGNUBase.getForm(),
         DIEInteger(LegacyRangesSectionWriter->getSectionOffset()));
     std::unique_ptr<DebugBufferVector> RangesWritersContents =
         LegacyRangesWriter->releaseBuffer();

@sayhaan sayhaan merged commit d283627 into llvm:main Jul 9, 2024
9 checks passed
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
Updates initialization to remove unnecessary use of std::optional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants