-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang] Use llvm::is_contained (NFC) #102999
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
[flang] Use llvm::is_contained (NFC) #102999
Conversation
@llvm/pr-subscribers-flang-semantics Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/102999.diff 2 Files Affected:
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 039dbcb82f7452..fcedf5ec3ddf83 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -2628,10 +2628,7 @@ bool IntrinsicProcTable::Implementation::IsDualIntrinsic(
static const std::string dualIntrinsic[]{
{"etime"s}, {"getcwd"s}, {"rename"s}, {"second"s}};
- return std::find_if(std::begin(dualIntrinsic), std::end(dualIntrinsic),
- [&name](const std::string &dualName) {
- return dualName == name;
- }) != std::end(dualIntrinsic);
+ return llvm::is_contained(dualIntrinsic, name);
}
IntrinsicClass IntrinsicProcTable::Implementation::GetIntrinsicClass(
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 1c0e541e4a36a7..26825468df9b1d 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1700,10 +1700,10 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
// map for it.
if (const Fortran::semantics::Symbol *common =
Fortran::semantics::FindCommonBlockContaining(sym.GetUltimate()))
- if (llvm::find(mapSyms, common) != mapSyms.end())
+ if (llvm::is_contained(mapSyms, common))
return;
- if (llvm::find(mapSyms, &sym) == mapSyms.end()) {
+ if (!llvm::is_contained(mapSyms, &sym)) {
mlir::Value baseOp = converter.getSymbolAddress(sym);
if (!baseOp)
if (const auto *details =
|
@llvm/pr-subscribers-flang-fir-hlfir Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/102999.diff 2 Files Affected:
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 039dbcb82f7452..fcedf5ec3ddf83 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -2628,10 +2628,7 @@ bool IntrinsicProcTable::Implementation::IsDualIntrinsic(
static const std::string dualIntrinsic[]{
{"etime"s}, {"getcwd"s}, {"rename"s}, {"second"s}};
- return std::find_if(std::begin(dualIntrinsic), std::end(dualIntrinsic),
- [&name](const std::string &dualName) {
- return dualName == name;
- }) != std::end(dualIntrinsic);
+ return llvm::is_contained(dualIntrinsic, name);
}
IntrinsicClass IntrinsicProcTable::Implementation::GetIntrinsicClass(
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 1c0e541e4a36a7..26825468df9b1d 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -1700,10 +1700,10 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
// map for it.
if (const Fortran::semantics::Symbol *common =
Fortran::semantics::FindCommonBlockContaining(sym.GetUltimate()))
- if (llvm::find(mapSyms, common) != mapSyms.end())
+ if (llvm::is_contained(mapSyms, common))
return;
- if (llvm::find(mapSyms, &sym) == mapSyms.end()) {
+ if (!llvm::is_contained(mapSyms, &sym)) {
mlir::Value baseOp = converter.getSymbolAddress(sym);
if (!baseOp)
if (const auto *details =
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a good change?
Because the new code accomplishes the same task with less code, specifically without repeating container names multiple times. |
But now it has more dependencies than just the standard library, which makes it less portable. It seems like a bad deal to me. |
No description provided.