-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-tools-extra] Use llvm::unique (NFC) #136514
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
[clang-tools-extra] Use llvm::unique (NFC) #136514
Conversation
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clang-tidy Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/136514.diff 3 Files Affected:
diff --git a/clang-tools-extra/clang-doc/Representation.cpp b/clang-tools-extra/clang-doc/Representation.cpp
index 54d2cb58ea2d9..9ab2f342d969a 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -200,7 +200,7 @@ void Info::mergeBase(Info &&Other) {
std::move(Other.Description.begin(), Other.Description.end(),
std::back_inserter(Description));
llvm::sort(Description);
- auto Last = std::unique(Description.begin(), Description.end());
+ auto Last = llvm::unique(Description);
Description.erase(Last, Description.end());
}
@@ -215,7 +215,7 @@ void SymbolInfo::merge(SymbolInfo &&Other) {
// Unconditionally extend the list of locations, since we want all of them.
std::move(Other.Loc.begin(), Other.Loc.end(), std::back_inserter(Loc));
llvm::sort(Loc);
- auto *Last = std::unique(Loc.begin(), Loc.end());
+ auto *Last = llvm::unique(Loc);
Loc.erase(Last, Loc.end());
mergeBase(std::move(Other));
}
diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
index d7369b162dc10..4eac0617ed4a9 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixerContext.cpp
@@ -90,10 +90,10 @@ IncludeFixerContext::IncludeFixerContext(
std::make_pair(B.Range.getOffset(), B.Range.getLength());
});
QuerySymbolInfos.erase(
- std::unique(QuerySymbolInfos.begin(), QuerySymbolInfos.end(),
- [](const QuerySymbolInfo &A, const QuerySymbolInfo &B) {
- return A.Range == B.Range;
- }),
+ llvm::unique(QuerySymbolInfos,
+ [](const QuerySymbolInfo &A, const QuerySymbolInfo &B) {
+ return A.Range == B.Range;
+ }),
QuerySymbolInfos.end());
for (const auto &Symbol : MatchedSymbols) {
HeaderInfos.push_back(
@@ -103,11 +103,11 @@ IncludeFixerContext::IncludeFixerContext(
QuerySymbolInfos.front().ScopedQualifiers, Symbol)});
}
// Deduplicate header infos.
- HeaderInfos.erase(std::unique(HeaderInfos.begin(), HeaderInfos.end(),
- [](const HeaderInfo &A, const HeaderInfo &B) {
- return A.Header == B.Header &&
- A.QualifiedName == B.QualifiedName;
- }),
+ HeaderInfos.erase(llvm::unique(HeaderInfos,
+ [](const HeaderInfo &A, const HeaderInfo &B) {
+ return A.Header == B.Header &&
+ A.QualifiedName == B.QualifiedName;
+ }),
HeaderInfos.end());
}
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 731141a545a48..b216970bfbd8c 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -754,8 +754,7 @@ std::vector<ClangTidyError> ClangTidyDiagnosticConsumer::take() {
finalizeLastError();
llvm::stable_sort(Errors, LessClangTidyError());
- Errors.erase(std::unique(Errors.begin(), Errors.end(), EqualClangTidyError()),
- Errors.end());
+ Errors.erase(llvm::unique(Errors, EqualClangTidyError()), Errors.end());
if (RemoveIncompatibleErrors)
removeIncompatibleErrors();
return std::move(Errors);
|
May I ask what is the reason for this change? What problem does std::unique have that llvm::unique solves? |
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/STLExtras.h has a collection of similar functions. |
Thanks for the clarification! |
No description provided.