-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AST] Construct iterator_range with the conversion constructor (NFC) #169245
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
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20251123_iterator_range_clang
Nov 24, 2025
Merged
[AST] Construct iterator_range with the conversion constructor (NFC) #169245
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20251123_iterator_range_clang
Nov 24, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This patch simplifies iterator_range construction with the conversion constructor.
Member
|
@llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) ChangesThis patch simplifies iterator_range construction with the conversion Patch is 21.69 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/169245.diff 1 Files Affected:
diff --git a/clang/include/clang/AST/OpenMPClause.h b/clang/include/clang/AST/OpenMPClause.h
index 7972d05bedbf7..72c5efde7449b 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -313,12 +313,8 @@ template <class T> class OMPVarListClause : public OMPClause {
unsigned varlist_size() const { return NumVars; }
bool varlist_empty() const { return NumVars == 0; }
- varlist_range varlist() {
- return varlist_range(varlist_begin(), varlist_end());
- }
- varlist_const_range varlist() const {
- return varlist_const_range(varlist_begin(), varlist_end());
- }
+ varlist_range varlist() { return getVarRefs(); }
+ varlist_const_range varlist() const { return getVarRefs(); }
varlist_iterator varlist_begin() { return getVarRefs().begin(); }
varlist_iterator varlist_end() { return getVarRefs().end(); }
@@ -3404,14 +3400,10 @@ class OMPPrivateClause final
using private_copies_const_range =
llvm::iterator_range<private_copies_const_iterator>;
- private_copies_range private_copies() {
- return private_copies_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
+ private_copies_range private_copies() { return getPrivateCopies(); }
private_copies_const_range private_copies() const {
- return private_copies_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
+ return getPrivateCopies();
}
child_range children() {
@@ -3531,13 +3523,9 @@ class OMPFirstprivateClause final
using private_copies_const_range =
llvm::iterator_range<private_copies_const_iterator>;
- private_copies_range private_copies() {
- return private_copies_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
+ private_copies_range private_copies() { return getPrivateCopies(); }
private_copies_const_range private_copies() const {
- return private_copies_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
+ return getPrivateCopies();
}
using inits_iterator = MutableArrayRef<Expr *>::iterator;
@@ -3545,12 +3533,8 @@ class OMPFirstprivateClause final
using inits_range = llvm::iterator_range<inits_iterator>;
using inits_const_range = llvm::iterator_range<inits_const_iterator>;
- inits_range inits() {
- return inits_range(getInits().begin(), getInits().end());
- }
- inits_const_range inits() const {
- return inits_const_range(getInits().begin(), getInits().end());
- }
+ inits_range inits() { return getInits(); }
+ inits_const_range inits() const { return getInits(); }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
@@ -3752,44 +3736,23 @@ class OMPLastprivateClause final
/// copies of original lastprivate variables.
void setPrivateCopies(ArrayRef<Expr *> PrivateCopies);
- helper_expr_const_range private_copies() const {
- return helper_expr_const_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
+ helper_expr_const_range private_copies() const { return getPrivateCopies(); }
- helper_expr_range private_copies() {
- return helper_expr_range(getPrivateCopies().begin(),
- getPrivateCopies().end());
- }
+ helper_expr_range private_copies() { return getPrivateCopies(); }
- helper_expr_const_range source_exprs() const {
- return helper_expr_const_range(getSourceExprs().begin(),
- getSourceExprs().end());
- }
+ helper_expr_const_range source_exprs() const { return getSourceExprs(); }
- helper_expr_range source_exprs() {
- return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
- }
+ helper_expr_range source_exprs() { return getSourceExprs(); }
helper_expr_const_range destination_exprs() const {
- return helper_expr_const_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
+ return getDestinationExprs();
}
- helper_expr_range destination_exprs() {
- return helper_expr_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
+ helper_expr_range destination_exprs() { return getDestinationExprs(); }
- helper_expr_const_range assignment_ops() const {
- return helper_expr_const_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
+ helper_expr_const_range assignment_ops() const { return getAssignmentOps(); }
- helper_expr_range assignment_ops() {
- return helper_expr_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
+ helper_expr_range assignment_ops() { return getAssignmentOps(); }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
@@ -4178,79 +4141,45 @@ class OMPReductionClause final
using helper_flag_const_range =
llvm::iterator_range<helper_flag_const_iterator>;
- helper_expr_const_range privates() const {
- return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
- }
+ helper_expr_const_range privates() const { return getPrivates(); }
- helper_expr_range privates() {
- return helper_expr_range(getPrivates().begin(), getPrivates().end());
- }
+ helper_expr_range privates() { return getPrivates(); }
- helper_expr_const_range lhs_exprs() const {
- return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
- }
+ helper_expr_const_range lhs_exprs() const { return getLHSExprs(); }
- helper_expr_range lhs_exprs() {
- return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
- }
+ helper_expr_range lhs_exprs() { return getLHSExprs(); }
- helper_expr_const_range rhs_exprs() const {
- return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
- }
+ helper_expr_const_range rhs_exprs() const { return getRHSExprs(); }
- helper_expr_range rhs_exprs() {
- return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
- }
+ helper_expr_range rhs_exprs() { return getRHSExprs(); }
helper_flag_const_range private_var_reduction_flags() const {
- return helper_flag_const_range(getPrivateVariableReductionFlags().begin(),
- getPrivateVariableReductionFlags().end());
+ return getPrivateVariableReductionFlags();
}
helper_flag_range private_var_reduction_flags() {
- return helper_flag_range(getPrivateVariableReductionFlags().begin(),
- getPrivateVariableReductionFlags().end());
+ return getPrivateVariableReductionFlags();
}
- helper_expr_const_range reduction_ops() const {
- return helper_expr_const_range(getReductionOps().begin(),
- getReductionOps().end());
- }
+ helper_expr_const_range reduction_ops() const { return getReductionOps(); }
- helper_expr_range reduction_ops() {
- return helper_expr_range(getReductionOps().begin(),
- getReductionOps().end());
- }
+ helper_expr_range reduction_ops() { return getReductionOps(); }
- helper_expr_const_range copy_ops() const {
- return helper_expr_const_range(getInscanCopyOps().begin(),
- getInscanCopyOps().end());
- }
+ helper_expr_const_range copy_ops() const { return getInscanCopyOps(); }
- helper_expr_range copy_ops() {
- return helper_expr_range(getInscanCopyOps().begin(),
- getInscanCopyOps().end());
- }
+ helper_expr_range copy_ops() { return getInscanCopyOps(); }
helper_expr_const_range copy_array_temps() const {
- return helper_expr_const_range(getInscanCopyArrayTemps().begin(),
- getInscanCopyArrayTemps().end());
+ return getInscanCopyArrayTemps();
}
- helper_expr_range copy_array_temps() {
- return helper_expr_range(getInscanCopyArrayTemps().begin(),
- getInscanCopyArrayTemps().end());
- }
+ helper_expr_range copy_array_temps() { return getInscanCopyArrayTemps(); }
helper_expr_const_range copy_array_elems() const {
- return helper_expr_const_range(getInscanCopyArrayElems().begin(),
- getInscanCopyArrayElems().end());
+ return getInscanCopyArrayElems();
}
- helper_expr_range copy_array_elems() {
- return helper_expr_range(getInscanCopyArrayElems().begin(),
- getInscanCopyArrayElems().end());
- }
+ helper_expr_range copy_array_elems() { return getInscanCopyArrayElems(); }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
@@ -4450,39 +4379,21 @@ class OMPTaskReductionClause final
using helper_expr_const_range =
llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range privates() const {
- return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
- }
+ helper_expr_const_range privates() const { return getPrivates(); }
- helper_expr_range privates() {
- return helper_expr_range(getPrivates().begin(), getPrivates().end());
- }
+ helper_expr_range privates() { return getPrivates(); }
- helper_expr_const_range lhs_exprs() const {
- return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
- }
+ helper_expr_const_range lhs_exprs() const { return getLHSExprs(); }
- helper_expr_range lhs_exprs() {
- return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
- }
+ helper_expr_range lhs_exprs() { return getLHSExprs(); }
- helper_expr_const_range rhs_exprs() const {
- return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
- }
+ helper_expr_const_range rhs_exprs() const { return getRHSExprs(); }
- helper_expr_range rhs_exprs() {
- return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
- }
+ helper_expr_range rhs_exprs() { return getRHSExprs(); }
- helper_expr_const_range reduction_ops() const {
- return helper_expr_const_range(getReductionOps().begin(),
- getReductionOps().end());
- }
+ helper_expr_const_range reduction_ops() const { return getReductionOps(); }
- helper_expr_range reduction_ops() {
- return helper_expr_range(getReductionOps().begin(),
- getReductionOps().end());
- }
+ helper_expr_range reduction_ops() { return getReductionOps(); }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
@@ -4694,48 +4605,28 @@ class OMPInReductionClause final
using helper_expr_const_range =
llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range privates() const {
- return helper_expr_const_range(getPrivates().begin(), getPrivates().end());
- }
+ helper_expr_const_range privates() const { return getPrivates(); }
- helper_expr_range privates() {
- return helper_expr_range(getPrivates().begin(), getPrivates().end());
- }
+ helper_expr_range privates() { return getPrivates(); }
- helper_expr_const_range lhs_exprs() const {
- return helper_expr_const_range(getLHSExprs().begin(), getLHSExprs().end());
- }
+ helper_expr_const_range lhs_exprs() const { return getLHSExprs(); }
- helper_expr_range lhs_exprs() {
- return helper_expr_range(getLHSExprs().begin(), getLHSExprs().end());
- }
+ helper_expr_range lhs_exprs() { return getLHSExprs(); }
- helper_expr_const_range rhs_exprs() const {
- return helper_expr_const_range(getRHSExprs().begin(), getRHSExprs().end());
- }
+ helper_expr_const_range rhs_exprs() const { return getRHSExprs(); }
- helper_expr_range rhs_exprs() {
- return helper_expr_range(getRHSExprs().begin(), getRHSExprs().end());
- }
+ helper_expr_range rhs_exprs() { return getRHSExprs(); }
- helper_expr_const_range reduction_ops() const {
- return helper_expr_const_range(getReductionOps().begin(),
- getReductionOps().end());
- }
+ helper_expr_const_range reduction_ops() const { return getReductionOps(); }
- helper_expr_range reduction_ops() {
- return helper_expr_range(getReductionOps().begin(),
- getReductionOps().end());
- }
+ helper_expr_range reduction_ops() { return getReductionOps(); }
helper_expr_const_range taskgroup_descriptors() const {
- return helper_expr_const_range(getTaskgroupDescriptors().begin(),
- getTaskgroupDescriptors().end());
+ return getTaskgroupDescriptors();
}
helper_expr_range taskgroup_descriptors() {
- return helper_expr_range(getTaskgroupDescriptors().begin(),
- getTaskgroupDescriptors().end());
+ return getTaskgroupDescriptors();
}
child_range children() {
@@ -4965,52 +4856,36 @@ class OMPLinearClause final
using privates_range = llvm::iterator_range<privates_iterator>;
using privates_const_range = llvm::iterator_range<privates_const_iterator>;
- privates_range privates() {
- return privates_range(getPrivates().begin(), getPrivates().end());
- }
+ privates_range privates() { return getPrivates(); }
- privates_const_range privates() const {
- return privates_const_range(getPrivates().begin(), getPrivates().end());
- }
+ privates_const_range privates() const { return getPrivates(); }
using inits_iterator = MutableArrayRef<Expr *>::iterator;
using inits_const_iterator = ArrayRef<const Expr *>::iterator;
using inits_range = llvm::iterator_range<inits_iterator>;
using inits_const_range = llvm::iterator_range<inits_const_iterator>;
- inits_range inits() {
- return inits_range(getInits().begin(), getInits().end());
- }
+ inits_range inits() { return getInits(); }
- inits_const_range inits() const {
- return inits_const_range(getInits().begin(), getInits().end());
- }
+ inits_const_range inits() const { return getInits(); }
using updates_iterator = MutableArrayRef<Expr *>::iterator;
using updates_const_iterator = ArrayRef<const Expr *>::iterator;
using updates_range = llvm::iterator_range<updates_iterator>;
using updates_const_range = llvm::iterator_range<updates_const_iterator>;
- updates_range updates() {
- return updates_range(getUpdates().begin(), getUpdates().end());
- }
+ updates_range updates() { return getUpdates(); }
- updates_const_range updates() const {
- return updates_const_range(getUpdates().begin(), getUpdates().end());
- }
+ updates_const_range updates() const { return getUpdates(); }
using finals_iterator = MutableArrayRef<Expr *>::iterator;
using finals_const_iterator = ArrayRef<const Expr *>::iterator;
using finals_range = llvm::iterator_range<finals_iterator>;
using finals_const_range = llvm::iterator_range<finals_const_iterator>;
- finals_range finals() {
- return finals_range(getFinals().begin(), getFinals().end());
- }
+ finals_range finals() { return getFinals(); }
- finals_const_range finals() const {
- return finals_const_range(getFinals().begin(), getFinals().end());
- }
+ finals_const_range finals() const { return getFinals(); }
using used_expressions_iterator = MutableArrayRef<Expr *>::iterator;
using used_expressions_const_iterator = ArrayRef<const Expr *>::iterator;
@@ -5270,34 +5145,19 @@ class OMPCopyinClause final
using helper_expr_const_range =
llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range source_exprs() const {
- return helper_expr_const_range(getSourceExprs().begin(),
- getSourceExprs().end());
- }
+ helper_expr_const_range source_exprs() const { return getSourceExprs(); }
- helper_expr_range source_exprs() {
- return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
- }
+ helper_expr_range source_exprs() { return getSourceExprs(); }
helper_expr_const_range destination_exprs() const {
- return helper_expr_const_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
+ return getDestinationExprs();
}
- helper_expr_range destination_exprs() {
- return helper_expr_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
+ helper_expr_range destination_exprs() { return getDestinationExprs(); }
- helper_expr_const_range assignment_ops() const {
- return helper_expr_const_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
+ helper_expr_const_range assignment_ops() const { return getAssignmentOps(); }
- helper_expr_range assignment_ops() {
- return helper_expr_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
+ helper_expr_range assignment_ops() { return getAssignmentOps(); }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
@@ -5433,34 +5293,19 @@ class OMPCopyprivateClause final
using helper_expr_const_range =
llvm::iterator_range<helper_expr_const_iterator>;
- helper_expr_const_range source_exprs() const {
- return helper_expr_const_range(getSourceExprs().begin(),
- getSourceExprs().end());
- }
+ helper_expr_const_range source_exprs() const { return getSourceExprs(); }
- helper_expr_range source_exprs() {
- return helper_expr_range(getSourceExprs().begin(), getSourceExprs().end());
- }
+ helper_expr_range source_exprs() { return getSourceExprs(); }
helper_expr_const_range destination_exprs() const {
- return helper_expr_const_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
+ return getDestinationExprs();
}
- helper_expr_range destination_exprs() {
- return helper_expr_range(getDestinationExprs().begin(),
- getDestinationExprs().end());
- }
+ helper_expr_range destination_exprs() { return getDestinationExprs(); }
- helper_expr_const_range assignment_ops() const {
- return helper_expr_const_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
+ helper_expr_const_range assignment_ops() const { return getAssignmentOps(); }
- helper_expr_range assignment_ops() {
- return helper_expr_range(getAssignmentOps().begin(),
- getAssignmentOps().end());
- }
+ helper_expr_range assignment_ops() { return getAssignmentOps(); }
child_range children() {
return child_range(reinterpret_cast<Stmt **>(varlist_begin()),
@@ -6632,18 +6477,14 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
using const_all_decls_iterator = ArrayRef<ValueDecl *>::iterator;
using const_all_decls_range = llvm::iterator_range<const_all_decls_iterator>;
- const_all_decls_range all_decls() const {
- auto A = getUniqueDeclsRef();
- return const_all_decls_range(A.begin(), A.end());
- }
+ const_all_decls_range all_decls() const { return getUniqueDeclsRef(); }
using const_all_num_lists_iterator = ArrayRef<unsigned>::iterator;
using const_all_num_lists_range =
llvm::iterator_range<const_all_num_lists_iterator>;
const_all_num_lists_range all_num_lists() const {
- auto A = getDeclNumListsRef();
- return const_all_num_lists_range(A.begin(), A.end());
+ return getDeclNumListsRef();
}
using const_all_lists_sizes_iterator = ArrayRef<unsigned>::iterator;
@@ -6651,8 +6492,7 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
llvm::iterator_range<const_all_lists_sizes_iterator>;
const_all_lists_sizes_range all_lists_sizes() const {
- auto A = getComponentListSizesRef();
- return const_all_lists_sizes_range(A.begin(), A.end());
+ return getComponentListSizesRef();
}
using const_all_components_iterator = ArrayRef<MappableComponent>::iterator;
@@ -6660,8 +6500,7 @@ class OMPMappableExprListClause : public OMPVarListClause<T>,
llvm::iterator_range<const_all_components_iterator>;
const_all_components_range all_components() const {
- auto A = getComponentsRef();
- return const_all_components_range(A.begin(), A.end());
+ ret...
[truncated]
|
shiltian
approved these changes
Nov 24, 2025
kuhar
approved these changes
Nov 24, 2025
aadeshps-mcw
pushed a commit
to aadeshps-mcw/llvm-project
that referenced
this pull request
Nov 26, 2025
…lvm#169245) This patch simplifies iterator_range construction with the conversion constructor.
Priyanshu3820
pushed a commit
to Priyanshu3820/llvm-project
that referenced
this pull request
Nov 26, 2025
…lvm#169245) This patch simplifies iterator_range construction with the conversion constructor.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang:openmp
OpenMP related changes to Clang
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch simplifies iterator_range construction with the conversion
constructor.