- Notifications
You must be signed in to change notification settings - Fork 15.3k
[clang] Use range constructors of *Set (NFC) #137574
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_001_set_range_clang Apr 28, 2025
Merged
[clang] Use range constructors of *Set (NFC) #137574
kazutakahirata merged 1 commit into llvm:main from kazutakahirata:cleanup_001_set_range_clang Apr 28, 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
Member
| @llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-analysis Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/137574.diff 5 Files Affected:
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp index 1c4fe5c6d5019..6409b4bc8ff4d 100644 --- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp +++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp @@ -86,7 +86,7 @@ StorageLocation &DataflowAnalysisContext::createStorageLocation(QualType Type) { // Can't use `StringSet` as the return type as it doesn't support `operator==`. template <typename T> static llvm::DenseSet<llvm::StringRef> getKeys(const llvm::StringMap<T> &Map) { - return llvm::DenseSet<llvm::StringRef>(Map.keys().begin(), Map.keys().end()); + return llvm::DenseSet<llvm::StringRef>(llvm::from_range, Map.keys()); } RecordStorageLocation &DataflowAnalysisContext::createRecordStorageLocation( diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp index f697c13f4c522..59a5f7b914ce5 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp @@ -129,8 +129,8 @@ static RecordDecl *buildRecordForGlobalizedVars( // }; RecordDecl *GlobalizedRD = C.buildImplicitRecord("_globalized_locals_ty"); GlobalizedRD->startDefinition(); - llvm::SmallPtrSet<const ValueDecl *, 16> SingleEscaped( - EscapedDeclsForTeams.begin(), EscapedDeclsForTeams.end()); + llvm::SmallPtrSet<const ValueDecl *, 16> SingleEscaped(llvm::from_range, + EscapedDeclsForTeams); for (const auto &Pair : GlobalizedVars) { const ValueDecl *VD = Pair.second; QualType Type = VD->getType(); @@ -322,8 +322,7 @@ class CheckVarsEscapingDeclContext final public: CheckVarsEscapingDeclContext(CodeGenFunction &CGF, ArrayRef<const ValueDecl *> TeamsReductions) - : CGF(CGF), EscapedDecls(TeamsReductions.begin(), TeamsReductions.end()) { - } + : CGF(CGF), EscapedDecls(llvm::from_range, TeamsReductions) {} virtual ~CheckVarsEscapingDeclContext() = default; void VisitDeclStmt(const DeclStmt *S) { if (!S) diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 87682233c5246..34fec069d6df6 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -498,7 +498,7 @@ bool Sema::DiagnoseUnexpandedParameterPackInRequiresExpr(RequiresExpr *RE) { // We only care about unexpanded references to the RequiresExpr's own // parameter packs. auto Parms = RE->getLocalParameters(); - llvm::SmallPtrSet<NamedDecl*, 8> ParmSet(Parms.begin(), Parms.end()); + llvm::SmallPtrSet<NamedDecl *, 8> ParmSet(llvm::from_range, Parms); SmallVector<UnexpandedParameterPack, 2> UnexpandedParms; for (auto Parm : Unexpanded) if (ParmSet.contains(Parm.first.dyn_cast<NamedDecl *>())) diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp index 90c95d5cf60d8..b88e6db7cceb7 100644 --- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp +++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp @@ -77,7 +77,7 @@ static int countSymbols(Lang Language) { } } #undef SYMBOL - return llvm::DenseSet<StringRef>(Symbols.begin(), Symbols.end()).size(); + return llvm::DenseSet<StringRef>(llvm::from_range, Symbols).size(); } static int initialize(Lang Language) { diff --git a/clang/unittests/Analysis/FlowSensitive/SimplifyConstraintsTest.cpp b/clang/unittests/Analysis/FlowSensitive/SimplifyConstraintsTest.cpp index 1f34ae076d5ed..c82199c15e068 100644 --- a/clang/unittests/Analysis/FlowSensitive/SimplifyConstraintsTest.cpp +++ b/clang/unittests/Analysis/FlowSensitive/SimplifyConstraintsTest.cpp @@ -24,8 +24,7 @@ class SimplifyConstraintsTest : public ::testing::Test { protected: llvm::SetVector<const Formula *> parse(StringRef Lines) { std::vector<const Formula *> formulas = test::parseFormulas(A, Lines); - llvm::SetVector<const Formula *> Constraints(formulas.begin(), - formulas.end()); + llvm::SetVector<const Formula *> Constraints(llvm::from_range, formulas); return Constraints; } |
kuhar approved these changes Apr 28, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:analysis clang:codegen IR generation bugs: mangling, exceptions, etc. clang:dataflow Clang Dataflow Analysis framework - https://clang.llvm.org/docs/DataFlowAnalysisIntro.html 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.
No description provided.