Skip to content

Commit 0877bc2

Browse files
kazutakahirataAlexisPerry
authored andcommitted
[Sema] Use llvm::erase_if (NFC) (llvm#96068)
While I am at it, I'm constructing SmallVector directly from ArrayRef.
1 parent 8fc14ad commit 0877bc2

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -841,14 +841,10 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitAttachClause(
841841

842842
// ActOnVar ensured that everything is a valid variable reference, but we
843843
// still have to make sure it is a pointer type.
844-
llvm::SmallVector<Expr *> VarList{Clause.getVarList().begin(),
845-
Clause.getVarList().end()};
846-
VarList.erase(std::remove_if(VarList.begin(), VarList.end(),
847-
[&](Expr *E) {
848-
return SemaRef.CheckVarIsPointerType(
849-
OpenACCClauseKind::Attach, E);
850-
}),
851-
VarList.end());
844+
llvm::SmallVector<Expr *> VarList{Clause.getVarList()};
845+
llvm::erase_if(VarList, [&](Expr *E) {
846+
return SemaRef.CheckVarIsPointerType(OpenACCClauseKind::Attach, E);
847+
});
852848
Clause.setVarListDetails(VarList,
853849
/*IsReadOnly=*/false, /*IsZero=*/false);
854850
return OpenACCAttachClause::Create(Ctx, Clause.getBeginLoc(),
@@ -866,14 +862,10 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitDevicePtrClause(
866862

867863
// ActOnVar ensured that everything is a valid variable reference, but we
868864
// still have to make sure it is a pointer type.
869-
llvm::SmallVector<Expr *> VarList{Clause.getVarList().begin(),
870-
Clause.getVarList().end()};
871-
VarList.erase(std::remove_if(VarList.begin(), VarList.end(),
872-
[&](Expr *E) {
873-
return SemaRef.CheckVarIsPointerType(
874-
OpenACCClauseKind::DevicePtr, E);
875-
}),
876-
VarList.end());
865+
llvm::SmallVector<Expr *> VarList{Clause.getVarList()};
866+
llvm::erase_if(VarList, [&](Expr *E) {
867+
return SemaRef.CheckVarIsPointerType(OpenACCClauseKind::DevicePtr, E);
868+
});
877869
Clause.setVarListDetails(VarList,
878870
/*IsReadOnly=*/false, /*IsZero=*/false);
879871

0 commit comments

Comments
 (0)