[clang] [Clang] Handle C++20 export declarations in -dump-minimization-hints (PR #151666)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 1 05:31:19 PDT 2025


================
@@ -205,12 +204,37 @@ class DeserializedDeclsSourceRangePrinter : public ASTConsumer,
 
 private:
   std::vector<const Decl *> PendingDecls;
-  llvm::DenseSet<const NamespaceDecl *> ProcessedNamespaces;
+  llvm::DenseSet<const DeclContext *> ProcessedDeclContexts;
   bool IsCollectingDecls = true;
   const SourceManager &SM;
   std::unique_ptr<llvm::raw_ostream> OS;
 
+  static bool shouldIncludeDeclsIn(const DeclContext *DC) {
+    assert(DC && "DC is null");
+    // We choose to work at namespace level to reduce complexity and the number
+    // of cases we care about.
+    // We still need to carefully handle composite declarations like
+    // `ExportDecl`.
+    for (; DC; DC = DC->getLexicalParent()) {
+      if (DC->isFileContext())
+        return true;
+      if (isa<ExportDecl>(DC))
+        continue; // Depends on the parent.
+      return false;
+    }
+    llvm_unreachable("DeclConext chain must end with a translation unit");
----------------
ilya-biryukov wrote:

fixed, thanks!

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


More information about the cfe-commits mailing list