[clangd] Use llvm::unique (NFC) (#136470)

This commit is contained in:
Kazu Hirata 2025-04-19 20:34:03 -07:00 committed by GitHub
parent f2ec5e40d9
commit 9bcb18db89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 23 additions and 28 deletions

View File

@ -484,7 +484,7 @@ collectAccessibleScopes(Sema &Sem, const DeclarationNameInfo &Typo, Scope *S,
/*IncludeGlobalScope=*/false,
/*LoadExternal=*/false);
llvm::sort(Scopes);
Scopes.erase(std::unique(Scopes.begin(), Scopes.end()), Scopes.end());
Scopes.erase(llvm::unique(Scopes), Scopes.end());
return Scopes;
}

View File

@ -1194,7 +1194,7 @@ std::vector<InlayHint> inlayHints(ParsedAST &AST,
// De-duplicate hints. Duplicates can sometimes occur due to e.g. explicit
// template instantiations.
llvm::sort(Results);
Results.erase(std::unique(Results.begin(), Results.end()), Results.end());
Results.erase(llvm::unique(Results), Results.end());
return Results;
}

View File

@ -489,7 +489,7 @@ public:
// Initializer lists can give duplicates of tokens, therefore all tokens
// must be deduplicated.
llvm::sort(Tokens);
auto Last = std::unique(Tokens.begin(), Tokens.end());
auto Last = llvm::unique(Tokens);
Tokens.erase(Last, Tokens.end());
// Macros can give tokens that have the same source range but conflicting

View File

@ -864,7 +864,7 @@ std::vector<std::string> visibleNamespaces(llvm::StringRef Code,
return true;
return LHS < RHS;
});
Found.erase(std::unique(Found.begin(), Found.end()), Found.end());
Found.erase(llvm::unique(Found), Found.end());
return Found;
}

View File

@ -909,7 +909,7 @@ public:
return std::tie(LTok, L.Role) < std::tie(RTok, R.Role);
});
// We sometimes see duplicates when parts of the AST get traversed twice.
References.erase(std::unique(References.begin(), References.end(),
References.erase(llvm::unique(References,
[](const Reference &L, const Reference &R) {
auto LTok = L.SpelledTok.location();
auto RTok = R.SpelledTok.location();
@ -1502,7 +1502,7 @@ ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
// We may get multiple refs with the same location and different Roles, as
// cross-reference is only interested in locations, we deduplicate them
// by the location to avoid emitting duplicated locations.
MainFileRefs.erase(std::unique(MainFileRefs.begin(), MainFileRefs.end(),
MainFileRefs.erase(llvm::unique(MainFileRefs,
[](const ReferenceFinder::Reference &L,
const ReferenceFinder::Reference &R) {
return L.SpelledTok.location() ==

View File

@ -370,8 +370,7 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling DuplicateHandle,
// relations being stored in both the shards containing their
// subject and object.
llvm::sort(AllRelations);
AllRelations.erase(std::unique(AllRelations.begin(), AllRelations.end()),
AllRelations.end());
AllRelations.erase(llvm::unique(AllRelations), AllRelations.end());
size_t StorageSize =
RefsStorage.size() * sizeof(Ref) + SymsStorage.size() * sizeof(Symbol);

View File

@ -43,8 +43,7 @@ RelationSlab RelationSlab::Builder::build() && {
llvm::sort(Relations);
// Remove duplicates.
Relations.erase(std::unique(Relations.begin(), Relations.end()),
Relations.end());
Relations.erase(llvm::unique(Relations), Relations.end());
return RelationSlab{std::move(Relations)};
}

View File

@ -116,7 +116,7 @@ void generateIdentifierTrigrams(llvm::StringRef Identifier,
} else {
identifierTrigrams(Identifier, [&](Trigram T) { Result.push_back(T); });
llvm::sort(Result);
Result.erase(std::unique(Result.begin(), Result.end()), Result.end());
Result.erase(llvm::unique(Result), Result.end());
}
}

View File

@ -906,7 +906,7 @@ findOccurrencesOutsideFile(const NamedDecl &RenameDecl,
for (auto &FileAndOccurrences : AffectedFiles) {
auto &Ranges = FileAndOccurrences.getValue();
llvm::sort(Ranges);
Ranges.erase(std::unique(Ranges.begin(), Ranges.end()), Ranges.end());
Ranges.erase(llvm::unique(Ranges), Ranges.end());
SPAN_ATTACH(Tracer, FileAndOccurrences.first(),
static_cast<int64_t>(Ranges.size()));
@ -1210,8 +1210,7 @@ llvm::Expected<Edit> buildRenameEdit(llvm::StringRef AbsFilePath,
static_cast<int64_t>(Occurrences.size()));
assert(llvm::is_sorted(Occurrences));
assert(std::unique(Occurrences.begin(), Occurrences.end()) ==
Occurrences.end() &&
assert(llvm::unique(Occurrences) == Occurrences.end() &&
"Occurrences must be unique");
// These two always correspond to the same position.

View File

@ -196,9 +196,7 @@ Expected<Tweak::Effect> RemoveUsingNamespace::apply(const Selection &Inputs) {
}
// Remove duplicates.
llvm::sort(IdentsToQualify);
IdentsToQualify.erase(
std::unique(IdentsToQualify.begin(), IdentsToQualify.end()),
IdentsToQualify.end());
IdentsToQualify.erase(llvm::unique(IdentsToQualify), IdentsToQualify.end());
// Produce replacements to remove the using directives.
tooling::Replacements R;