[clang] [Sema] Use llvm::erase_if (NFC) (PR #96068)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 19 06:17:08 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

While I am at it, I'm constructing SmallVector directly from ArrayRef.

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


1 Files Affected:

- (modified) clang/lib/Sema/SemaOpenACC.cpp (+8-16) 


``````````diff
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 97586a037eee4..cf207be33175c 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -841,14 +841,10 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitAttachClause(
 
   // ActOnVar ensured that everything is a valid variable reference, but we
   // still have to make sure it is a pointer type.
-  llvm::SmallVector<Expr *> VarList{Clause.getVarList().begin(),
-                                    Clause.getVarList().end()};
-  VarList.erase(std::remove_if(VarList.begin(), VarList.end(),
-                               [&](Expr *E) {
-                                 return SemaRef.CheckVarIsPointerType(
-                                     OpenACCClauseKind::Attach, E);
-                               }),
-                VarList.end());
+  llvm::SmallVector<Expr *> VarList{Clause.getVarList()};
+  llvm::erase_if(VarList, [&](Expr *E) {
+    return SemaRef.CheckVarIsPointerType(OpenACCClauseKind::Attach, E);
+  });
   Clause.setVarListDetails(VarList,
                            /*IsReadOnly=*/false, /*IsZero=*/false);
   return OpenACCAttachClause::Create(Ctx, Clause.getBeginLoc(),
@@ -866,14 +862,10 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitDevicePtrClause(
 
   // ActOnVar ensured that everything is a valid variable reference, but we
   // still have to make sure it is a pointer type.
-  llvm::SmallVector<Expr *> VarList{Clause.getVarList().begin(),
-                                    Clause.getVarList().end()};
-  VarList.erase(std::remove_if(VarList.begin(), VarList.end(),
-                               [&](Expr *E) {
-                                 return SemaRef.CheckVarIsPointerType(
-                                     OpenACCClauseKind::DevicePtr, E);
-                               }),
-                VarList.end());
+  llvm::SmallVector<Expr *> VarList{Clause.getVarList()};
+  llvm::erase_if(VarList, [&](Expr *E) {
+    return SemaRef.CheckVarIsPointerType(OpenACCClauseKind::DevicePtr, E);
+  });
   Clause.setVarListDetails(VarList,
                            /*IsReadOnly=*/false, /*IsZero=*/false);
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/96068


More information about the cfe-commits mailing list