Skip to content

[clang] Use llvm::unique (NFC) #136469

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5975,7 +5975,7 @@ SortAndUniqueProtocols(SmallVectorImpl<ObjCProtocolDecl *> &Protocols) {
P = P->getCanonicalDecl();

// Remove duplicates.
auto ProtocolsEnd = std::unique(Protocols.begin(), Protocols.end());
auto ProtocolsEnd = llvm::unique(Protocols);
Protocols.erase(ProtocolsEnd, Protocols.end());
}

Expand Down
5 changes: 2 additions & 3 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class CXXNameMangler {
}

llvm::sort(TagList);
TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
TagList.erase(llvm::unique(TagList), TagList.end());

writeSortedUniqueAbiTags(Out, TagList);
}
Expand All @@ -344,8 +344,7 @@ class CXXNameMangler {

const AbiTagList &getSortedUniqueUsedAbiTags() {
llvm::sort(UsedAbiTags);
UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
UsedAbiTags.end());
UsedAbiTags.erase(llvm::unique(UsedAbiTags), UsedAbiTags.end());
return UsedAbiTags;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ ToolChain::getMultilibFlags(const llvm::opt::ArgList &Args) const {

// Sort and remove duplicates.
std::sort(Result.begin(), Result.end());
Result.erase(std::unique(Result.begin(), Result.end()), Result.end());
Result.erase(llvm::unique(Result), Result.end());
return Result;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/XRayArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {

// Then we want to sort and unique the modes we've collected.
llvm::sort(Modes);
Modes.erase(std::unique(Modes.begin(), Modes.end()), Modes.end());
Modes.erase(llvm::unique(Modes), Modes.end());
}

void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args,
Expand Down
18 changes: 9 additions & 9 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3244,11 +3244,11 @@ static void sortCppIncludes(const FormatStyle &Style,
}

// Deduplicate #includes.
Indices.erase(std::unique(Indices.begin(), Indices.end(),
[&](unsigned LHSI, unsigned RHSI) {
return Includes[LHSI].Text.trim() ==
Includes[RHSI].Text.trim();
}),
Indices.erase(llvm::unique(Indices,
[&](unsigned LHSI, unsigned RHSI) {
return Includes[LHSI].Text.trim() ==
Includes[RHSI].Text.trim();
}),
Indices.end());

int CurrentCategory = Includes.front().Category;
Expand Down Expand Up @@ -3476,10 +3476,10 @@ static void sortJavaImports(const FormatStyle &Style,
});

// Deduplicate imports.
Indices.erase(std::unique(Indices.begin(), Indices.end(),
[&](unsigned LHSI, unsigned RHSI) {
return Imports[LHSI].Text == Imports[RHSI].Text;
}),
Indices.erase(llvm::unique(Indices,
[&](unsigned LHSI, unsigned RHSI) {
return Imports[LHSI].Text == Imports[RHSI].Text;
}),
Indices.end());

bool CurrentIsStatic = Imports[Indices.front()].IsStatic;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) {

// Repeating the same attribute is fine.
llvm::sort(Names);
Names.erase(std::unique(Names.begin(), Names.end()), Names.end());
Names.erase(llvm::unique(Names), Names.end());

// Empty no_builtin must be on its own.
if (HasWildcard && Names.size() > 1)
Expand Down Expand Up @@ -6037,7 +6037,7 @@ static void handleAbiTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {

// Store tags sorted and without duplicates.
llvm::sort(Tags);
Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
Tags.erase(llvm::unique(Tags), Tags.end());

D->addAttr(::new (S.Context)
AbiTagAttr(S.Context, AL, Tags.data(), Tags.size()));
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1623,8 +1623,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
EnumVals.push_back(std::make_pair(Val, EDI));
}
llvm::stable_sort(EnumVals, CmpEnumVals);
auto EI = EnumVals.begin(), EIEnd =
std::unique(EnumVals.begin(), EnumVals.end(), EqEnumVals);
auto EI = EnumVals.begin(), EIEnd = llvm::unique(EnumVals, EqEnumVals);

// See which case values aren't in enum.
for (CaseValsTy::const_iterator CI = CaseVals.begin();
Expand Down Expand Up @@ -1777,8 +1776,7 @@ Sema::DiagnoseAssignmentEnum(QualType DstType, QualType SrcType,
if (EnumVals.empty())
return;
llvm::stable_sort(EnumVals, CmpEnumVals);
EnumValsTy::iterator EIend =
std::unique(EnumVals.begin(), EnumVals.end(), EqEnumVals);
EnumValsTy::iterator EIend = llvm::unique(EnumVals, EqEnumVals);

// See which values aren't in the enum.
EnumValsTy::const_iterator EI = EnumVals.begin();
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6094,8 +6094,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema *SemaPtr, StringRef isysroot,

// Sort and deduplicate module IDs.
llvm::sort(Imports, Cmp);
Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
Imports.end());
Imports.erase(llvm::unique(Imports, Eq), Imports.end());

RecordData ImportedModules;
for (const auto &Import : Imports) {
Expand Down
3 changes: 1 addition & 2 deletions clang/utils/TableGen/NeonEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,8 +2052,7 @@ void NeonEmitter::createIntrinsic(const Record *R,
}

sort(NewTypeSpecs);
NewTypeSpecs.erase(std::unique(NewTypeSpecs.begin(), NewTypeSpecs.end()),
NewTypeSpecs.end());
NewTypeSpecs.erase(llvm::unique(NewTypeSpecs), NewTypeSpecs.end());
auto &Entry = IntrinsicMap[Name];

for (auto &I : NewTypeSpecs) {
Expand Down
3 changes: 1 addition & 2 deletions clang/utils/TableGen/SveEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,8 +1231,7 @@ void SVEEmitter::createIntrinsic(

// Remove duplicate type specs.
sort(TypeSpecs);
TypeSpecs.erase(std::unique(TypeSpecs.begin(), TypeSpecs.end()),
TypeSpecs.end());
TypeSpecs.erase(llvm::unique(TypeSpecs), TypeSpecs.end());

// Create an Intrinsic for each type spec.
for (auto TS : TypeSpecs) {
Expand Down
Loading