[clang] [Serialization] [ASTWriter] Try to not record namespace as much as possible (PR #179178)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 01:50:31 PDT 2026


================
@@ -2234,8 +2234,15 @@ void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
       // redecl chain.
       unsigned I = Record.size();
       Record.push_back(0);
-      if (Writer.Chain)
-        AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/false);
+      if (Writer.Chain) {
+        // Namespace can have many redeclaration in many TU.
+        // We try to avoid touching every redeclaration to try to
+        // reduce the dependencies as much as possible.
+        if (!isa<NamespaceDecl>(DAsT))
+          AddFirstDeclFromEachModule(DAsT, /*IncludeLocal*/ false);
----------------
ChuanqiXu9 wrote:

Done

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


More information about the cfe-commits mailing list