[clang-tools-extra] [clang-tidy] Switch misc-confusable-identifiers check to a faster algorithm. (PR #130369)

via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 7 15:42:14 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 1b75b9e665ee3c43de85c25f8d5f10d4efb3ca39 870c0ea0c6dde2232ad63ec51f968007702cef90 --extensions h,cpp -- clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
index 70b948c078..85f7515cc8 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
@@ -93,7 +93,7 @@ struct Entry {
   const NamedDecl *ND;
   bool FromDerivedClass;
 };
-}
+} // namespace
 
 using DeclsWithinContextMap =
     llvm::DenseMap<const DeclContext *, llvm::SmallVector<Entry, 1>>;
@@ -158,7 +158,7 @@ void ConfusableIdentifierCheck::check(
 }
 
 void ConfusableIdentifierCheck::onEndOfTranslationUnit() {
-  llvm::StringMap<llvm::SmallVector<const IdentifierInfo*, 1>> SkeletonToNames;
+  llvm::StringMap<llvm::SmallVector<const IdentifierInfo *, 1>> SkeletonToNames;
   // Compute the skeleton for each identifier.
   for (auto &[Ident, Decls] : NameToDecls) {
     SkeletonToNames[skeleton(Ident->getName())].push_back(Ident);
@@ -209,7 +209,7 @@ void ConfusableIdentifierCheck::onEndOfTranslationUnit() {
           diag(Inner.ND->getLocation(), "%0 is confusable with %1")
               << Inner.ND << OuterND;
           diag(OuterND->getLocation(), "other declaration found here",
-                DiagnosticIDs::Note);
+               DiagnosticIDs::Note);
         }
       }
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/130369


More information about the cfe-commits mailing list