[clang] [clang][tools] Handle weak (and duplicate) symbols in clang-extdef-mapping (PR #222010)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 9 02:35:35 PDT 2026


================
@@ -43,25 +43,26 @@ class MapExtDefNamesConsumer : public ASTConsumer {
     CurrentFileName = astFilePath.str();
   }
 
-  ~MapExtDefNamesConsumer() {
-    // Flush results to standard output.
-    llvm::outs() << createCrossTUIndexString(Index);
-  }
-
   void HandleTranslationUnit(ASTContext &Context) override {
     handleDecl(Context.getTranslationUnitDecl());
   }
 
+  static void printIndex() { llvm::outs() << createCrossTUIndexString(Index); }
+
 private:
   void handleDecl(const Decl *D);
   void addIfInMain(const DeclaratorDecl *DD, SourceLocation defStart);
 
   ASTContext &Ctx;
   SourceManager &SM;
-  llvm::StringMap<std::string> Index;
+  static llvm::StringMap<std::string> Index;
+  static llvm::StringSet<> WeakNames;
----------------
NagyDonat wrote:

Your commit doesn't actually use `WeakNames`: it inserts some filenames and erases some, but I don't see any code that checks or prints it.

If you forgot to add some  logic, then add it, otherwise you should delete `WeakNames`.

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


More information about the cfe-commits mailing list