https://github.com/ChuanqiXu9 created 
https://github.com/llvm/llvm-project/pull/187212

In the original code, the operation to iterate Found is meaningless, as it is 
guarded by Found.empty(). So this is always a noop for 10 years.

According to the context, I believe the intention is to avoid duplicated DeclID 
to be in Data. So changing iterating Found to Data.

Just found by looking around the code.

This is not strictly NFC but NFC intentionally. I will be surprised if this 
breaks anything.

>From 2000ffb8e353b39133fcac458ff1ce81cacd1759 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu <[email protected]>
Date: Wed, 18 Mar 2026 16:29:15 +0800
Subject: [PATCH] [NFCI] [Serialization] Deduplicate DeclID properly

In the original code, the operation to iterate Found is meaningless,
as it is guarded by Found.empty(). So this is always a noop for 10
years.

According to the context, I believe the intention is to avoid duplicated
DeclID to be in Data. So changing iterating Found to Data.

Just found by looking around the code.

This is not strictly NFC but NFC intentionally. I will be surprised if
this breaks anything.
---
 clang/lib/Serialization/ASTReaderInternals.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Serialization/ASTReaderInternals.h 
b/clang/lib/Serialization/ASTReaderInternals.h
index 4a7794889b039..a132d01a21128 100644
--- a/clang/lib/Serialization/ASTReaderInternals.h
+++ b/clang/lib/Serialization/ASTReaderInternals.h
@@ -61,7 +61,7 @@ class ASTDeclContextNameLookupTraitBase {
       // Just use a linear scan unless we have more than a few IDs.
       if (Found.empty() && !Data.empty()) {
         if (Data.size() <= 4) {
-          for (auto I : Found)
+          for (auto I : Data)
             if (I == ID)
               return;
           Data.push_back(ID);
@@ -183,7 +183,7 @@ class LazySpecializationInfoLookupTrait {
       // Just use a linear scan unless we have more than a few IDs.
       if (Found.empty() && !Data.empty()) {
         if (Data.size() <= 4) {
-          for (auto I : Found)
+          for (auto I : Data)
             if (I == Info)
               return;
           Data.push_back(Info);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to