[clang-tools-extra] [clang-tidy] Avoid repeated hash lookups (NFC) (PR #111785)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 9 20:12:08 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111785
None
>From 14e7f5dd2176e4fbde0fd699e5a7088239d8faf0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 9 Oct 2024 06:52:33 -0700
Subject: [PATCH] [clang-tidy] Avoid repeated hash lookups (NFC)
---
.../clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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