Skip to content

[llvm][Object] Add missing const qualifier for value_type in content_iterator #124106

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 3 commits into from
Jan 28, 2025

Conversation

dybv-sc
Copy link
Contributor

@dybv-sc dybv-sc commented Jan 23, 2025

value_type was defined as non-const for content_iterator, although it's methods returned a const pointers/references. This prevented it from using in some algorithms from STLExtras.h

…iterator.

value_type was defined as non-const for content_iterator, although it's methods
returned a const pointers/references. This prevented it from using in some
algorithms from STLExtras.h
@llvmbot
Copy link
Member

llvmbot commented Jan 23, 2025

@llvm/pr-subscribers-llvm-binary-utilities

Author: Bushev Dmitry (dybv-sc)

Changes

value_type was defined as non-const for content_iterator, although it's methods returned a const pointers/references. This prevented it from using in some algorithms from STLExtras.h


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

1 Files Affected:

  • (modified) llvm/include/llvm/Object/SymbolicFile.h (+1-1)
diff --git a/llvm/include/llvm/Object/SymbolicFile.h b/llvm/include/llvm/Object/SymbolicFile.h
index b13588c147d9b2..2c857e72c3e5a6 100644
--- a/llvm/include/llvm/Object/SymbolicFile.h
+++ b/llvm/include/llvm/Object/SymbolicFile.h
@@ -71,7 +71,7 @@ template <class content_type> class content_iterator {
 
 public:
   using iterator_category = std::forward_iterator_tag;
-  using value_type = content_type;
+  using value_type = const content_type;
   using difference_type = std::ptrdiff_t;
   using pointer = value_type *;
   using reference = value_type &;

@dybv-sc dybv-sc requested review from dwblaikie and kuhar January 23, 2025 13:21
Copy link
Member

@kuhar kuhar left a comment

Choose a reason for hiding this comment

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

Can have a test for this?

@dybv-sc
Copy link
Contributor Author

dybv-sc commented Jan 24, 2025

Can have a test for this?

@kuhar, sure, added unit test

Copy link

github-actions bot commented Jan 24, 2025

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

@dybv-sc dybv-sc force-pushed the object-iterator-const-missing-fix branch from 790e62b to 27d2197 Compare January 24, 2025 19:23
@dybv-sc dybv-sc requested a review from kuhar January 24, 2025 19:24
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this blank line. Headers should be included as one contiguous block, otherwise clang-format won't sort them properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@atamazov
Copy link

@dybv-sc I think this PR have collected enough feedback, let's resolve review comments, thanks!

@dybv-sc dybv-sc requested a review from jh7370 January 27, 2025 17:24
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.

No more comments from me. Happy once others are.

@dybv-sc dybv-sc merged commit 0165e33 into llvm:main Jan 28, 2025
8 checks passed
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.

5 participants