Skip to content

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

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested review from arsenm and shiltian May 18, 2025 15:38
@llvmbot llvmbot added clang Clang issues not falling into any other category clang-format clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang:as-a-library libclang and C++ API labels May 18, 2025
@llvmbot
Copy link
Member

llvmbot commented May 18, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-modules

Author: Kazu Hirata (kazutakahirata)

Changes

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

4 Files Affected:

  • (modified) clang/include/clang/Serialization/ContinuousRangeMap.h (+2-2)
  • (modified) clang/lib/Format/UsingDeclarationsSorter.cpp (+4-5)
  • (modified) clang/lib/Sema/SemaLambda.cpp (+2-2)
  • (modified) clang/tools/libclang/CIndex.cpp (+2-3)
diff --git a/clang/include/clang/Serialization/ContinuousRangeMap.h b/clang/include/clang/Serialization/ContinuousRangeMap.h
index c2665c097416d..3c4b03866d27a 100644
--- a/clang/include/clang/Serialization/ContinuousRangeMap.h
+++ b/clang/include/clang/Serialization/ContinuousRangeMap.h
@@ -119,8 +119,8 @@ class ContinuousRangeMap {
     ~Builder() {
       llvm::sort(Self.Rep, Compare());
       Self.Rep.erase(
-          std::unique(
-              Self.Rep.begin(), Self.Rep.end(),
+          llvm::unique(
+              Self.Rep,
               [](const_reference A, const_reference B) {
                 // FIXME: we should not allow any duplicate keys, but there are
                 // a lot of duplicate 0 -> 0 mappings to remove first.
diff --git a/clang/lib/Format/UsingDeclarationsSorter.cpp b/clang/lib/Format/UsingDeclarationsSorter.cpp
index 2f4b1e0e46270..651471899dc87 100644
--- a/clang/lib/Format/UsingDeclarationsSorter.cpp
+++ b/clang/lib/Format/UsingDeclarationsSorter.cpp
@@ -157,11 +157,10 @@ void endUsingDeclarationBlock(
   };
   llvm::stable_sort(SortedUsingDeclarations, Comp);
   SortedUsingDeclarations.erase(
-      std::unique(SortedUsingDeclarations.begin(),
-                  SortedUsingDeclarations.end(),
-                  [](const UsingDeclaration &a, const UsingDeclaration &b) {
-                    return a.Label == b.Label;
-                  }),
+      llvm::unique(SortedUsingDeclarations,
+                   [](const UsingDeclaration &a, const UsingDeclaration &b) {
+                     return a.Label == b.Label;
+                   }),
       SortedUsingDeclarations.end());
   for (size_t I = 0, E = UsingDeclarations->size(); I < E; ++I) {
     if (I >= SortedUsingDeclarations.size()) {
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index 28fcef829ec41..f3addfc15735c 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1633,8 +1633,8 @@ static void repeatForLambdaConversionFunctionCallingConvs(
         CC_C,        CC_X86StdCall, CC_X86FastCall, CC_X86VectorCall,
         DefaultFree, DefaultMember, CallOpCC};
     llvm::sort(Convs);
-    llvm::iterator_range<CallingConv *> Range(
-        std::begin(Convs), std::unique(std::begin(Convs), std::end(Convs)));
+    llvm::iterator_range<CallingConv *> Range(std::begin(Convs),
+                                              llvm::unique(Convs));
     const TargetInfo &TI = S.getASTContext().getTargetInfo();
 
     for (CallingConv C : Range) {
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 9163c87ea7717..06a17006fdee9 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -8872,9 +8872,8 @@ static void getCursorPlatformAvailabilityForDecl(
         return LHS->getPlatform()->getName() < RHS->getPlatform()->getName();
       });
   ASTContext &Ctx = D->getASTContext();
-  auto It = std::unique(
-      AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
-      [&Ctx](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+  auto It = llvm::unique(
+      AvailabilityAttrs, [&Ctx](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
         if (LHS->getPlatform() != RHS->getPlatform())
           return false;
 

@kazutakahirata kazutakahirata merged commit 0fc9cd1 into llvm:main May 18, 2025
19 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_llvm_unique_clang branch May 18, 2025 16:47
ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:as-a-library libclang and C++ API clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category clang-format
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants