[clang-tools-extra] 670a461 - [clang-tidy] Avoid repeated hash lookups (NFC) (#111785)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 08:17:29 PDT 2024


Author: Kazu Hirata
Date: 2024-10-10T08:17:25-07:00
New Revision: 670a4613fc5f29036f23fe357b0dbf017d019717

URL: https://github.com/llvm/llvm-project/commit/670a4613fc5f29036f23fe357b0dbf017d019717
DIFF: https://github.com/llvm/llvm-project/commit/670a4613fc5f29036f23fe357b0dbf017d019717.diff

LOG: [clang-tidy] Avoid repeated hash lookups (NFC) (#111785)

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
index d77df50f8fea24..080454287f28b5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
@@ -146,12 +146,13 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
       }
       // Check if a definition in another namespace exists.
       const auto DeclName = CurDecl->getName();
-      if (!DeclNameToDefinitions.contains(DeclName)) {
+      auto It = DeclNameToDefinitions.find(DeclName);
+      if (It == DeclNameToDefinitions.end()) {
         continue; // No definition in this translation unit, we can skip it.
       }
       // Make a warning for each definition with the same name (in other
       // namespaces).
-      const auto &Definitions = DeclNameToDefinitions[DeclName];
+      const auto &Definitions = It->second;
       for (const auto *Def : Definitions) {
         diag(CurDecl->getLocation(),
              "no definition found for %0, but a definition with "


        


More information about the cfe-commits mailing list