Skip to content

[llvm][ELF][build attributes] Change StringRef to std::string for BuildAttributeSubSection::Name#135625

Merged
sivan-shani merged 1 commit intollvm:mainfrom
sivan-shani:stringref2string1
Apr 14, 2025
Merged

[llvm][ELF][build attributes] Change StringRef to std::string for BuildAttributeSubSection::Name#135625
sivan-shani merged 1 commit intollvm:mainfrom
sivan-shani:stringref2string1

Conversation

@sivan-shani
Copy link
Copy Markdown
Contributor

BuildAttributeSubSection::Name must be a std::string instead of StringRef because it may be assigned from non-persistent memory. StringRef is non-owning and unsafe in this context. This change ensures the subsection name owns its memory, preventing use-after-free or dangling references.

Context: Work in progress in PR #131990.

…ldAttributeSubSection::Name

BuildAttributeSubSection::Name must be a std::string instead of StringRef because it may be assigned from non-persistent memory. StringRef is non-owning and unsafe in this context.
This change ensures the subsection name owns its memory, preventing use-after-free or dangling references.

Context: Work in progress in PR llvm#131990.
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 14, 2025

@llvm/pr-subscribers-llvm-support

Author: SivanShani-Arm (sivan-shani)

Changes

BuildAttributeSubSection::Name must be a std::string instead of StringRef because it may be assigned from non-persistent memory. StringRef is non-owning and unsafe in this context. This change ensures the subsection name owns its memory, preventing use-after-free or dangling references.

Context: Work in progress in PR #131990.


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

1 Files Affected:

  • (modified) llvm/include/llvm/Support/ELFAttributes.h (+1-1)
diff --git a/llvm/include/llvm/Support/ELFAttributes.h b/llvm/include/llvm/Support/ELFAttributes.h
index 6782aec6050ad..d652e2586e9e5 100644
--- a/llvm/include/llvm/Support/ELFAttributes.h
+++ b/llvm/include/llvm/Support/ELFAttributes.h
@@ -36,7 +36,7 @@ struct BuildAttributeItem {
       : Type(Ty), Tag(Tg), IntValue(IV), StringValue(std::move(SV)) {}
 };
 struct BuildAttributeSubSection {
-  StringRef Name;
+  std::string Name;
   unsigned IsOptional;
   unsigned ParameterType;
   SmallVector<BuildAttributeItem, 64> Content;

Copy link
Copy Markdown
Contributor

@Stylie777 Stylie777 left a comment

Choose a reason for hiding this comment

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

LGTM.

@sivan-shani sivan-shani merged commit bcbdbd2 into llvm:main Apr 14, 2025
8 of 12 checks passed
@sivan-shani sivan-shani deleted the stringref2string1 branch April 14, 2025 14:20
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.

3 participants